jsoup
jsoup copied to clipboard
Fix NullPointerException in case a custom document is passed to W3CDom
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)
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!
Great, TY!
Thank you @jhy!