]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
- SF bug #853506: IP6 address parsing in sgmllib
authorFred Drake <fdrake@acm.org>
Fri, 23 Jun 2006 06:12:31 +0000 (06:12 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 23 Jun 2006 06:12:31 +0000 (06:12 +0000)
  ('[' and ']' were not accepted in unquoted attribute values)

Lib/sgmllib.py
Lib/test/test_sgmllib.py

index 08e365bdef99e20e60c480095823ed8e1c72832e..634c837605c612d565adf0457474e25955b94b09 100644 (file)
@@ -33,7 +33,7 @@ endbracket = re.compile('[<>]')
 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 bc25bd0195cf9bc2e1166377cecbc0f901a38006..5edad9753a6c11a1b0034755dc130908405d80f5 100644 (file)
@@ -219,6 +219,14 @@ DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'
             ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]),
             ])
 
+    def test_attr_value_ip6_url(self):
+        # http://www.python.org/sf/853506
+        self.check_events(("<a href='http://[1080::8:800:200C:417A]/'>"
+                           "<a href=http://[1080::8:800:200C:417A]/>"), [
+            ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]),
+            ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]),
+            ])
+
     def test_illegal_declarations(self):
         s = 'abc<!spacer type="block" height="25">def'
         self.check_events(s, [