diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-04-19 01:08:41 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-04-19 01:08:41 (GMT) |
commit | c45868ec697a70a80d1cf8a511894f073fda3a27 (patch) | |
tree | 1f8e79a1d86c7efa99e160ecda477eab7a14b27b /Lib/HTMLParser.py | |
parent | a72aa843b66e80cc6f97a5e3571952d941e82404 (diff) | |
download | cpython-c45868ec697a70a80d1cf8a511894f073fda3a27.zip cpython-c45868ec697a70a80d1cf8a511894f073fda3a27.tar.gz cpython-c45868ec697a70a80d1cf8a511894f073fda3a27.tar.bz2 |
#14538: HTMLParser can now parse correctly start tags that contain a bare /.
Diffstat (limited to 'Lib/HTMLParser.py')
-rw-r--r-- | Lib/HTMLParser.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/HTMLParser.py b/Lib/HTMLParser.py index d4e14d4..b336a4c 100644 --- a/Lib/HTMLParser.py +++ b/Lib/HTMLParser.py @@ -22,13 +22,13 @@ charref = re.compile('&#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]') starttagopen = re.compile('<[a-zA-Z]') piclose = re.compile('>') commentclose = re.compile(r'--\s*>') -tagfind = re.compile('[a-zA-Z][-.a-zA-Z0-9:_]*') +tagfind = re.compile('([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*') # see http://www.w3.org/TR/html5/tokenization.html#tag-open-state # and http://www.w3.org/TR/html5/tokenization.html#tag-name-state tagfind_tolerant = re.compile('[a-zA-Z][^\t\n\r\f />\x00]*') attrfind = re.compile( - r'[\s/]*((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*' + r'((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*' r'(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*') locatestarttagend = re.compile(r""" @@ -289,7 +289,7 @@ class HTMLParser(markupbase.ParserBase): match = tagfind.match(rawdata, i+1) assert match, 'unexpected call to parse_starttag()' k = match.end() - self.lasttag = tag = rawdata[i+1:k].lower() + self.lasttag = tag = match.group(1).lower() while k < endpos: m = attrfind.match(rawdata, k) |