cpython: 225400cb6e84 (original) (raw)

--- a/Lib/html/parser.py +++ b/Lib/html/parser.py @@ -28,7 +28,7 @@ tagfind = re.compile('[a-zA-Z][-.a-zA-Z0

make it correctly strict without breaking backward compatibility.

attrfind = re.compile( r'\s*([a-zA-Z_][-.:a-zA-Z_0-9])(\s=\s*'

attrfind_tolerant = re.compile( r'\s*([a-zA-Z_][-.:a-zA-Z_0-9])(\s=\s*' r'('[^']'|"[^"]"|[^>\s]*))?')

--- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -217,6 +217,23 @@ DOCTYPE html [ ("starttag", "a", [("href", "mailto:xyz@example.com")]), ])

+ def test_attr_entity_replacement(self): self._run_check("""""", [ ("starttag", "a", [("b", "&><"'")]),

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -49,6 +49,8 @@ Core and Builtins Library ------- +- Issue #7311: fix html.parser to accept non-ASCII attribute values. +