Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d2307cb4
Commit
d2307cb4
authored
Feb 15, 2012
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#13987: HTMLParser is now able to handle EOFs in the middle of a construct.
parent
fd7e4964
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
11 deletions
+21
-11
Lib/HTMLParser.py
Lib/HTMLParser.py
+10
-3
Lib/test/test_htmlparser.py
Lib/test/test_htmlparser.py
+8
-8
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/HTMLParser.py
View file @
d2307cb4
...
...
@@ -170,9 +170,16 @@ class HTMLParser(markupbase.ParserBase):
else:
break
if k < 0:
if end:
self.error("EOF in middle of construct")
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)
...
...
Lib/test/test_htmlparser.py
View file @
d2307cb4
...
...
@@ -204,16 +204,16 @@ text
def
test_starttag_junk_chars
(
self
):
self
.
_run_check
(
"</>"
,
[])
self
.
_run_check
(
"</$>"
,
[(
'comment'
,
'$'
)])
self
.
_
parse_error
(
"</"
)
self
.
_
parse_error
(
"</a"
)
self
.
_
run_check
(
"</"
,
[(
'data'
,
'</'
)]
)
self
.
_
run_check
(
"</a"
,
[(
'data'
,
'</a'
)]
)
self
.
_parse_error
(
"<a<a>"
)
self
.
_run_check
(
"</a<a>"
,
[(
'endtag'
,
'a<a'
)])
self
.
_
parse_error
(
"<!"
)
self
.
_
parse_error
(
"<a"
)
self
.
_
parse_error
(
"<a foo='bar'"
)
self
.
_
parse_error
(
"<a foo='bar"
)
self
.
_
parse_error
(
"<a foo='>'"
)
self
.
_
parse_error
(
"<a foo='>"
)
self
.
_
run_check
(
"<!"
,
[(
'data'
,
'<!'
)]
)
self
.
_
run_check
(
"<a"
,
[(
'data'
,
'<a'
)]
)
self
.
_
run_check
(
"<a foo='bar'"
,
[(
'data'
,
"<a foo='bar'"
)]
)
self
.
_
run_check
(
"<a foo='bar"
,
[(
'data'
,
"<a foo='bar"
)]
)
self
.
_
run_check
(
"<a foo='>'"
,
[(
'data'
,
"<a foo='>'"
)]
)
self
.
_
run_check
(
"<a foo='>"
,
[(
'data'
,
"<a foo='>"
)]
)
def
test_valid_doctypes
(
self
):
# from http://www.w3.org/QA/2002/04/valid-dtd-list.html
...
...
Misc/NEWS
View file @
d2307cb4
...
...
@@ -93,6 +93,9 @@ Core and Builtins
Library
-------
- Issue #13987: HTMLParser is now able to handle EOFs in the middle of a
construct.
- Issue #13015: Fix a possible reference leak in defaultdict.__repr__.
Patch by Suman Saha.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment