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
{{ message }}
Repository navigation
There's null issue in org.jsoup.select.Elements#set #2212
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)
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.
Activity
test case for Issue jhy#2212
MicyToy commentedon Oct 23, 2024
I've pushed a test case for this.
Issue 2212
test case for Issue jhy#2212
test case for Issue jhy#2212
test case for Issue #2212
Use the incoming node's parent if outgoing has already been removed
jhy commentedon Nov 25, 2024
Thanks, I added support for that case.
When calling
setor 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.chore(deps): update all non-major dependencies (mulk/mulkcms2!58)