8000 Handle empty script src · awesome-python/html5lib-python@38b151a · GitHub
[go: up one dir, main page]

Skip to content

Commit 38b151a

Browse files
committed
Handle empty script src
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40824
1 parent b25e933 commit 38b151a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/html5lib/liberalxmlparser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def normalizeToken(self, token):
4040

4141
# For EmptyTags, process both a Start and an End tag
4242
if token["type"] == "EmptyTag":
43+
save = self.tokenizer.contentModelFlag
4344
self.phase.processStartTag(token["name"], token["data"])
45+
self.tokenizer.contentModelFlag = save
4446
token["data"] = {}
4547
token["type"] = "EndTag"
4648

tests/test_lxp.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@ def test_script(self):
198198
<head><title>SCRIPT</title></head>
199199
<body>
200200
<script>1 &lt; 2 &amp; 3</script>
201+
</body></html>""")
202+
203+
def test_script_src(self):
204+
self.assertXhtmlEquals("""<html xmlns="http://www.w3.org/1999/xhtml">
205+
<head><title>SCRIPT</title><script src="http://example.com"/></head>
206+
<body>
207+
</body></html>""",
208+
"""<html xmlns="http://www.w3.org/1999/xhtml">
209+
<head><title>SCRIPT</title><script src="http://example.com"></script></head>
210+
<body>
201211
</body></html>""")
202212

203213
def test_title(self):

0 commit comments

Comments
 (0)
0