From: Fred Drake Date: Fri, 23 Jun 2006 06:12:31 +0000 (+0000) Subject: - SF bug #853506: IP6 address parsing in sgmllib X-Git-Tag: v2.4.4c1~170 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44b01932b316f09f4bbbd6b148c9ab10778fc293;p=thirdparty%2FPython%2Fcpython.git - SF bug #853506: IP6 address parsing in sgmllib ('[' and ']' were not accepted in unquoted attribute values) --- diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py index 08e365bdef99..634c837605c6 100644 --- a/Lib/sgmllib.py +++ b/Lib/sgmllib.py @@ -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): diff --git a/Lib/test/test_sgmllib.py b/Lib/test/test_sgmllib.py index bc25bd0195cf..5edad9753a6c 100644 --- a/Lib/test/test_sgmllib.py +++ b/Lib/test/test_sgmllib.py @@ -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(("" + ""), [ + ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]), + ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]), + ]) + def test_illegal_declarations(self): s = 'abcdef' self.check_events(s, [