Skip to content

etree treewalker infinite loop #217

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
gsnedders opened this issue Dec 3, 2015 · 3 comments
Closed

etree treewalker infinite loop #217

gsnedders opened this issue Dec 3, 2015 · 3 comments
Assignees
Milestone

Comments

@gsnedders
Copy link
Member

This goes into an infinite loop:

import html5lib

frag = html5lib.parseFragment("<b><em><foo><foob><fooc><aside></b></em>")

walker = html5lib.getTreeWalker("etree")

print list(walker(frag))
@gsnedders gsnedders self-assigned this Dec 3, 2015
@gsnedders
Copy link
Member Author

This is weird.

(Pdb) print list(frag)
[<Element u'{http://www.w3.org/1999/xhtml}b' at 0x7fdd8eb42990>, <Element u'{http://www.w3.org/1999/xhtml}aside' at 0x7fdd8eb42e10>, <Element u'{http://www.w3.org/1999/xhtml}aside' at 0x7fdd8eb42e10>]

Note it's a fragment containing the same element twice.

@gsnedders
Copy link
Member Author

It's still strictly a tree, though, so I don't think the tree walker should break so badly?

gsnedders added a commit to gsnedders/html5lib-python that referenced this issue Dec 3, 2015
Also add an assertion for symptom of html5lib#217 (without this the
testsuite goes into an infinite loop; this doesn't fix the cause
but it avoids the infinite loop happening!).
@gsnedders
Copy link
Member Author

list(parents[-1]).index(parent) in the etree walker is why. The above commit adds an assertion that the count is 1, which at least prevents the infinite loop.

gsnedders added a commit to gsnedders/html5lib-python that referenced this issue Dec 3, 2015
Also add an assertion for symptom of html5lib#217 (without this the
testsuite goes into an infinite loop; this doesn't fix the cause
but it avoids the infinite loop happening!).
@gsnedders gsnedders modified the milestone: 0.99999999 Dec 3, 2015
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue Dec 3, 2015
Also add an assertion for symptom of html5lib#217 (without this the
testsuite goes into an infinite loop; this doesn't fix the cause
but it avoids the infinite loop happening!).
gsnedders added a commit to gsnedders/html5lib-tests that referenced this issue May 28, 2016
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue May 28, 2016
…ilder

This adds a test here because we still fail the upstream one, as
our implementation of AAA is outdated.
gsnedders added a commit to gsnedders/html5lib-python that referenced this issue May 28, 2016
gsnedders added a commit that referenced this issue May 29, 2016
)

This adds a test here because we still fail the upstream one, as
our implementation of AAA is outdated.
zcorpan pushed a commit to html5lib/html5lib-tests that referenced this issue Jun 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant