Skip to content

Fixing SVG close tag bug #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ Patches and suggestions
- Juan Carlos Garcia Segovia
- Mike West
- Marc DM
- Sam Cooke
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Change Log

Released on XXX, 2014

* Fix: SVG end tags were not being adjusted

* XXX


Expand Down
2 changes: 2 additions & 0 deletions html5lib/html5parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2445,6 +2445,8 @@ def processStartTag(self, token):
def processEndTag(self, token):
nodeIndex = len(self.tree.openElements) - 1
node = self.tree.openElements[-1]
if node.namespace == namespaces["svg"]:
self.adjustSVGTagNames(token)
if node.name != token["name"]:
self.parser.parseError("unexpected-end-tag", {"name": token["name"]})

Expand Down
4 changes: 4 additions & 0 deletions html5lib/tests/test_parser2.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def test_unicode_file(self):
parser = html5parser.HTMLParser()
parser.parse(io.StringIO("a"))

def test_svg_token(self):
parser = html5parser.HTMLParser(strict=True)
parser.parseFragment("<svg><switch><foreignObject></foreignObject></switch></svg>")


def buildTestSuite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)
Expand Down