Mercurial > cpython-lru_cache-weakref
diff Lib/HTMLParser.py @ 74945:11a31eb5da93 2.7
#13987: HTMLParser is now able to handle EOFs in the middle of a construct.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Wed, 15 Feb 2012 12:44:23 +0200 |
| parents | 4743a3a1e669 |
| children | 3d7904e3f4b9 |
line wrap: on
line diff
--- a/Lib/HTMLParser.py Wed Feb 15 02:57:19 2012 +0100 +++ b/Lib/HTMLParser.py Wed Feb 15 12:44:23 2012 +0200 @@ -170,9 +170,16 @@ else: break if k < 0: - if end: - self.error("EOF in middle of construct") - break + if not end: + break + k = rawdata.find('>', i + 1) + if k < 0: + k = rawdata.find('<', i + 1) + if k < 0: + k = i + 1 + else: + k += 1 + self.handle_data(rawdata[i:k]) i = self.updatepos(i, k) elif startswith("&#", i): match = charref.match(rawdata, i)
