mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
#23144: merge with 3.4.
This commit is contained in:
commit
20a2c6482e
3 changed files with 26 additions and 5 deletions
|
@ -139,7 +139,15 @@ class HTMLParser(_markupbase.ParserBase):
|
|||
if self.convert_charrefs and not self.cdata_elem:
|
||||
j = rawdata.find('<', i)
|
||||
if j < 0:
|
||||
if not end:
|
||||
# if we can't find the next <, either we are at the end
|
||||
# or there's more text incoming. If the latter is True,
|
||||
# we can't pass the text to handle_data in case we have
|
||||
# a charref cut in half at end. Try to determine if
|
||||
# this is the case before proceding by looking for an
|
||||
# & near the end and see if it's followed by a space or ;.
|
||||
amppos = rawdata.rfind('&', max(i, n-34))
|
||||
if (amppos >= 0 and
|
||||
not re.compile(r'[\s;]').search(rawdata, amppos)):
|
||||
break # wait till we get all the text
|
||||
j = n
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue