Skip to content
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

There's null issue in org.jsoup.select.Elements#set #2212

Open
MicyToy opened this issue Oct 12, 2024 · 1 comment
Open

There's null issue in org.jsoup.select.Elements#set #2212

MicyToy opened this issue Oct 12, 2024 · 1 comment

Comments

@MicyToy
Copy link

MicyToy commented Oct 12, 2024

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()

MicyToy added a commit to MicyToy/jsoup that referenced this issue Oct 23, 2024
@MicyToy
Copy link
Author

MicyToy commented Oct 23, 2024

I've pushed a test case for this.
Issue 2212

MicyToy added a commit to MicyToy/jsoup that referenced this issue Oct 23, 2024
MicyToy added a commit to MicyToy/jsoup that referenced this issue Oct 23, 2024
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

4 participants
@MicyToy and others