Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed our HTMLParser patches for python 2.7.4

  • Loading branch information...
commit 6bc1b222994301782bd80780bdeec8c4eb44631a 1 parent a54a8ba
@apollo13 apollo13 authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 django/utils/html_parser.py
View
6 django/utils/html_parser.py
@@ -1,6 +1,7 @@
import HTMLParser as _HTMLParser
import re
+tagfind = re.compile('([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*')
class HTMLParser(_HTMLParser.HTMLParser):
"""
@@ -33,10 +34,10 @@ def parse_starttag(self, i):
# Now parse the data between i+1 and j into a tag and attrs
attrs = []
- match = _HTMLParser.tagfind.match(rawdata, i + 1)
+ 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 = _HTMLParser.attrfind.match(rawdata, k)
@@ -48,6 +49,7 @@ def parse_starttag(self, i):
elif attrvalue[:1] == '\'' == attrvalue[-1:] or \
attrvalue[:1] == '"' == attrvalue[-1:]:
attrvalue = attrvalue[1:-1]
+ if attrvalue:
attrvalue = self.unescape(attrvalue)
attrs.append((attrname.lower(), attrvalue))
k = m.end()
Please sign in to comment.
Something went wrong with that request. Please try again.