Whether you can inject a Javascript:alert(0) as a link
(html: str)
| 365 | return False |
| 366 | |
| 367 | def inject_javascript_handler(html: str) -> bool: |
| 368 | """Whether you can inject a Javascript:alert(0) as a link""" |
| 369 | |
| 370 | class injectJSHandlerHTMLParser(HTMLParser): |
| 371 | injectJSHandler = False |
| 372 | |
| 373 | def handle_starttag(self, tag, attrs): |
| 374 | for name, value in attrs: |
| 375 | if name == "href" and value.startswith(FRONT_WALL.decode("utf-8")): |
| 376 | self.injectJSHandler = True |
| 377 | |
| 378 | parser = injectJSHandlerHTMLParser() |
| 379 | parser.feed(html) |
| 380 | return parser.injectJSHandler |
| 381 | |
| 382 | # Only convert the body to bytes if needed |
| 383 | if isinstance(body, str): |
no test coverage detected
searching dependent graphs…