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
ca9afca0
Commit
ca9afca0
authored
Dec 19, 2011
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Plain Diff
#13576: merge with 3.2.
parents
5ce6f8ed
62f3d030
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
Lib/_markupbase.py
Lib/_markupbase.py
+4
-0
Lib/test/test_htmlparser.py
Lib/test/test_htmlparser.py
+43
-0
No files found.
Lib/_markupbase.py
View file @
ca9afca0
...
...
@@ -107,6 +107,10 @@ class ParserBase:
if decltype == "doctype":
self.handle_decl(data)
else:
# According to the HTML5 specs sections "8.2.4.44 Bogus
# comment state" and "8.2.4.45 Markup declaration open
# state", a comment token should be emitted.
# Calling unknown_decl provides more flexibility though.
self.unknown_decl(data)
return j + 1
if c in "
\
"
'":
...
...
Lib/test/test_htmlparser.py
View file @
ca9afca0
...
...
@@ -323,6 +323,16 @@ DOCTYPE html [
(
"endtag"
,
element_lower
)],
collector
=
Collector
())
def
test_condcoms
(
self
):
html
=
(
'<!--[if IE & !(lte IE 8)]>aren
\
'
t<![endif]-->'
'<!--[if IE 8]>condcoms<![endif]-->'
'<!--[if lte IE 7]>pretty?<![endif]-->'
)
expected
=
[(
'comment'
,
"[if IE & !(lte IE 8)]>aren't<![endif]"
),
(
'comment'
,
'[if IE 8]>condcoms<![endif]'
),
(
'comment'
,
'[if lte IE 7]>pretty?<![endif]'
)]
self
.
_run_check
(
html
,
expected
)
class
HTMLParserTolerantTestCase
(
HTMLParserStrictTestCase
):
def
get_collector
(
self
):
...
...
@@ -416,6 +426,39 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase):
# see #12888
self
.
assertEqual
(
p
.
unescape
(
'{ '
*
1050
),
'{ '
*
1050
)
def
test_broken_condcoms
(
self
):
# these condcoms are missing the '--' after '<!' and before the '>'
html
=
(
'<![if !(IE)]>broken condcom<![endif]>'
'<![if ! IE]><link href="favicon.tiff"/><![endif]>'
'<![if !IE 6]><img src="firefox.png" /><![endif]>'
'<![if !ie 6]><b>foo</b><![endif]>'
'<![if (!IE)|(lt IE 9)]><img src="mammoth.bmp" /><![endif]>'
)
# According to the HTML5 specs sections "8.2.4.44 Bogus comment state"
# and "8.2.4.45 Markup declaration open state", comment tokens should
# be emitted instead of 'unknown decl', but calling unknown_decl
# provides more flexibility.
# See also Lib/_markupbase.py:parse_declaration
expected
=
[
(
'unknown decl'
,
'if !(IE)'
),
(
'data'
,
'broken condcom'
),
(
'unknown decl'
,
'endif'
),
(
'unknown decl'
,
'if ! IE'
),
(
'startendtag'
,
'link'
,
[(
'href'
,
'favicon.tiff'
)]),
(
'unknown decl'
,
'endif'
),
(
'unknown decl'
,
'if !IE 6'
),
(
'startendtag'
,
'img'
,
[(
'src'
,
'firefox.png'
)]),
(
'unknown decl'
,
'endif'
),
(
'unknown decl'
,
'if !ie 6'
),
(
'starttag'
,
'b'
,
[]),
(
'data'
,
'foo'
),
(
'endtag'
,
'b'
),
(
'unknown decl'
,
'endif'
),
(
'unknown decl'
,
'if (!IE)|(lt IE 9)'
),
(
'startendtag'
,
'img'
,
[(
'src'
,
'mammoth.bmp'
)]),
(
'unknown decl'
,
'endif'
)
]
self
.
_run_check
(
html
,
expected
)
class
AttributesStrictTestCase
(
TestCaseBase
):
...
...
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