diff options
author | jvoisin <julien.voisin@dustri.org> | 2019-12-15 06:50:54 -0800 |
---|---|---|
committer | jvoisin <julien.voisin@dustri.org> | 2019-12-15 06:50:54 -0800 |
commit | efa525c10213964c2ea6bf4e5c07b9bb058ee674 (patch) | |
tree | e4a45689d4c64692e4730fdfaf9cabd82a61ebb1 | |
parent | f67cd9d7dcf465bb83597cf9dd64fb8b6bc053db (diff) | |
download | external_mat2-efa525c10213964c2ea6bf4e5c07b9bb058ee674.tar.gz external_mat2-efa525c10213964c2ea6bf4e5c07b9bb058ee674.tar.bz2 external_mat2-efa525c10213964c2ea6bf4e5c07b9bb058ee674.zip |
Improve the robustness of the HTML parser
-rw-r--r-- | libmat2/web.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libmat2/web.py b/libmat2/web.py index 2864d60..8843c1e 100644 --- a/libmat2/web.py +++ b/libmat2/web.py @@ -104,6 +104,15 @@ class _HTMLParser(parser.HTMLParser): self.tag_required_blocklist = required_blocklisted_tags self.tag_blocklist = blocklisted_tags + def error(self, message): # pragma: no cover + """ Amusingly, Python's documentation doesn't mention that this + function needs to be implemented in subclasses of the parent class + of parser.HTMLParser. This was found by fuzzing, + triggering the following exception: + NotImplementedError: subclasses of ParserBase must override error() + """ + raise ValueError(message) + def handle_starttag(self, tag: str, attrs: List[Tuple[str, Optional[str]]]): # Ignore the type, because mypy is too stupid to infer # that get_starttag_text() can't return None. |