-
-
Notifications
You must be signed in to change notification settings - Fork 902
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
Hangs forever when trying to replace a child node with the parent node #1912
Comments
@sebastianiorga How fascinating! Thanks for reporting, I'll definitely take a look. If possible I'd like to raise an exception if an infinite loop like this is going to occur. |
The same happens with |
No. |
We'll fix this in v1.11.0, likely with a check that a parent's ancestors don't include the current node (which will be a performance penalty). |
See #2311 |
Describe the bug
If you(stupidly) try to replace a child node of a parent node with the parent node itself, nokogiri just hangs forever. I traced the issue into
xml_node.c
I believe it's thereparent_node_with
function that hangs, but I'm not a C dev so didn't dig deeper.ctrl-c
also doesn't work, you need to kill the ruby process to close it.To Reproduce
Run the script below.
Expected behavior
Crash with some sort of error message like: 'Don't do this you dummy.' Presumably this affects more complicated types of accidentally recursive replacements as well, though I haven't checked those.
Environment
Please paste the output from
nokogiri -v
here, escaped by triple-backtick.The text was updated successfully, but these errors were encountered: