You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the new org.jsoup.select.Elements#set(int, Element) method since 1.17.1 has an issue.
this call old.replaceWith(element) method, and this method calls parentNode.replaceChild(this, in). in the replaceChild method, out's parentNode is removed out.parentNode = null;. this may cause an null issue.
eg: a parent node has 5 child elements, if I replace the 3rd element twice, eg: first replace 1 with 3, and then replace 3 with 5, then will throw an exception.
org.jsoup.helper.ValidationException: Object must not be null
at org.jsoup.nodes.Node.replaceWith(Node.java:512)
at org.jsoup.select.Elements.set(Elements.java:703)
at org.jsoup.select.Elements.set(Elements.java:30)
you also can test it with Collections.shuffle()
The text was updated successfully, but these errors were encountered:
MicyToy
added a commit
to MicyToy/jsoup
that referenced
this issue
Oct 23, 2024
When calling set or other methods which re-parent nodes, the outgoing node is detached from the DOM by removing its parent. So now the replaceChild method tests to see if the outgoing node has a parent, and if not will fall back to trying to use the incoming node's parent. If that doesn't have a parent either, the flow will necessarily still abandon.
the new
org.jsoup.select.Elements#set(int, Element)
method since 1.17.1 has an issue.this call
old.replaceWith(element)
method, and this method callsparentNode.replaceChild(this, in)
. in thereplaceChild
method, out's parentNode is removedout.parentNode = null;
. this may cause an null issue.eg: a parent node has 5 child elements, if I replace the 3rd element twice, eg: first replace 1 with 3, and then replace 3 with 5, then will throw an exception.
you also can test it with
Collections.shuffle()
The text was updated successfully, but these errors were encountered: