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

Fix NullPointerException in case a custom document is passed to W3CDom #2114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

casid
Copy link

@casid casid commented Feb 1, 2024

When we provide a custom output Document to W3CDom#convert, we receive a NullPointerException in the W3CBuilder constructor.

I've added a test that demonstrates the behavior. Here's the stacktrace from that test without the applied fix.

java.lang.NullPointerException: Cannot invoke "org.jsoup.nodes.Element.ownerDocument()" because "this.contextElement" is null

	at org.jsoup.helper.W3CDom$W3CBuilder.<init>(W3CDom.java:364)
	at org.jsoup.helper.W3CDom.convert(W3CDom.java:250)
	at org.jsoup.helper.W3CDom.convert(W3CDom.java:238)
	at org.jsoup.helper.W3CDomTest.canConvertToCustomDocument(W3CDomTest.java:199)

@casid
Copy link
Author

casid commented Apr 23, 2024

Hi @jhy,

did you get a chance to have a look at this already?

It is not urgent, but it prevents us from upgrading to the latest JSOUP version without hacking the classpath.

Thank you so much!

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

Successfully merging this pull request may close these issues.

None yet

2 participants