]> granicus.if.org Git - python/commitdiff
Accept commas in unquoted attribute values.
authorFred Drake <fdrake@acm.org>
Fri, 14 Mar 2003 16:21:57 +0000 (16:21 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 14 Mar 2003 16:21:57 +0000 (16:21 +0000)
This closes SF patch #669683.

Lib/HTMLParser.py
Lib/sgmllib.py
Lib/test/test_htmlparser.py
Lib/test/test_sgmllib.py

index 908b30ebd03bbf6c595c050bb9546227a9d81010..c082fde527b327b66cee5f2cafdd3ee56338a138 100644 (file)
@@ -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
index 021c8b5cf65bac731ad3917a300a912aa29358f5..a4f0a8b75152244640ee7b1c6110cfc946befb81 100644 (file)
@@ -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):
index 8422751cef0949fe75f194cea74317c07ee68b52..a10c40b2e20a7d8b3817d661976434f7bcbd3e2a 100755 (executable)
@@ -197,6 +197,10 @@ DOCTYPE html [
         self._run_check("""<a b='' c="">""", [
             ("starttag", "a", [("b", ""), ("c", "")]),
             ])
+        # Regression test for SF patch #669683.
+        self._run_check("<e a=rgb(1,2,3)>", [
+            ("starttag", "e", [("a", "rgb(1,2,3)")]),
+            ])
 
     def test_attr_entity_replacement(self):
         self._run_check("""<a b='&amp;&gt;&lt;&quot;&apos;'>""", [
index 90ed87ee82ea11f239a7f3ca42ae18a15ec0fd72..6f4454f8f3fb1f3485dc2dfbee0ca2d3d41acabd 100644 (file)
@@ -200,6 +200,10 @@ DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'
         self.check_events("""<a b='' c="">""", [
             ("starttag", "a", [("b", ""), ("c", "")]),
             ])
+        # Regression test for SF patch #669683.
+        self.check_events("<e a=rgb(1,2,3)>", [
+            ("starttag", "e", [("a", "rgb(1,2,3)")]),
+            ])
 
     def test_attr_funky_names(self):
         self.check_events("""<a a.b='v' c:d=v e-f=v>""", [