From 0834d77bc4f07e5632588ed636b6db21e87694cc Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Fri, 14 Mar 2003 16:21:57 +0000 Subject: [PATCH] Accept commas in unquoted attribute values. This closes SF patch #669683. --- Lib/HTMLParser.py | 2 +- Lib/sgmllib.py | 2 +- Lib/test/test_htmlparser.py | 4 ++++ Lib/test/test_sgmllib.py | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Lib/HTMLParser.py b/Lib/HTMLParser.py index 908b30ebd0..c082fde527 100644 --- a/Lib/HTMLParser.py +++ b/Lib/HTMLParser.py @@ -26,7 +26,7 @@ commentclose = re.compile(r'--\s*>') tagfind = re.compile('[a-zA-Z][-.a-zA-Z0-9:_]*') attrfind = re.compile( r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*' - r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:;+*%?!&$\(\)_#=~]*))?') + r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~]*))?') locatestarttagend = re.compile(r""" <[a-zA-Z][-.a-zA-Z0-9:_]* # tag name diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py index 021c8b5cf6..a4f0a8b751 100644 --- a/Lib/sgmllib.py +++ b/Lib/sgmllib.py @@ -34,7 +34,7 @@ commentclose = re.compile(r'--\s*>') tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*') attrfind = re.compile( r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' - r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./:;+*%?!&$\(\)_#=~\'"]*))?') + r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"]*))?') class SGMLParseError(RuntimeError): diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index 8422751cef..a10c40b2e2 100755 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -197,6 +197,10 @@ DOCTYPE html [ self._run_check("""""", [ ("starttag", "a", [("b", ""), ("c", "")]), ]) + # Regression test for SF patch #669683. + self._run_check("", [ + ("starttag", "e", [("a", "rgb(1,2,3)")]), + ]) def test_attr_entity_replacement(self): self._run_check("""""", [ diff --git a/Lib/test/test_sgmllib.py b/Lib/test/test_sgmllib.py index 90ed87ee82..6f4454f8f3 100644 --- a/Lib/test/test_sgmllib.py +++ b/Lib/test/test_sgmllib.py @@ -200,6 +200,10 @@ DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' self.check_events("""""", [ ("starttag", "a", [("b", ""), ("c", "")]), ]) + # Regression test for SF patch #669683. + self.check_events("", [ + ("starttag", "e", [("a", "rgb(1,2,3)")]), + ]) def test_attr_funky_names(self): self.check_events("""""", [ -- 2.50.1