Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e021f4b

Browse files
author
Victor Stinner
committed
Recorded merge of revisions 81500-81501 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r81500 | victor.stinner | 2010-05-24 23:33:24 +0200 (lun., 24 mai 2010) | 2 lines Issue #6662: Fix parsing of malformatted charref (&#bad;) ........ r81501 | victor.stinner | 2010-05-24 23:37:28 +0200 (lun., 24 mai 2010) | 2 lines Add the author of the last fix (Issue #6662) ........
1 parent ec883db commit e021f4b

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

Lib/html/parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ def goahead(self, end):
175175
i = self.updatepos(i, k)
176176
continue
177177
else:
178+
if ";" in rawdata[i:]: #bail by consuming &#
179+
self.handle_data(rawdata[0:2])
180+
i = self.updatepos(i, 2)
178181
break
179182
elif startswith('&', i):
180183
match = entityref.match(rawdata, i)

Lib/test/test_htmlparser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ def test_simple_html(self):
136136
("data", "\n"),
137137
])
138138

139+
def test_malformatted_charref(self):
140+
self._run_check("<p>&#bad;</p>", [
141+
("starttag", "p", []),
142+
("data", "&#bad;"),
143+
("endtag", "p"),
144+
])
145+
139146
def test_unclosed_entityref(self):
140147
self._run_check("&entityref foo", [
141148
("entityref", "entityref"),

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,3 +871,4 @@ Siebren van der Zee
871871
Uwe Zessin
872872
Tarek Ziadé
873873
Peter Åstrand
874+
Fredrik Håård

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ C-API
392392
Library
393393
-------
394394

395+
- Issue #6662: Fix parsing of malformatted charref (&#bad;), patch written by
396+
Fredrik Håård
397+
395398
- Issue #8540: Decimal module: rename the Context._clamp attribute to
396399
Context.clamp and make it public. This is useful in creating
397400
contexts that correspond to the decimal interchange formats

0 commit comments

Comments
 (0)