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
I am using jsoup 1.18.3 and noticed a ugly behaviour in comparison to jsoup 1.18.0.
I call jsoup like this: Document doc = Jsoup.parse(stream, null, "");
It happens that the stream is null. This is detected by another part of my program and jsoup previously accepted the null stream. In org.jsoup.helper.DataUtil.parseInputStream(ControllableInputStream, String, String, Parser) it simply returned new Document(baseUri).
With one of the recent changes you wrap a ControllableInputStream.wrap around the stream object. Therefore the check
if (input == null) // empty body // todo reconsider?
return new Document(baseUri);
at the top of org.jsoup.helper.DataUtil.parseInputStream(ControllableInputStream, String, String, Parser) will never return a new Document when the stream is null. Instead it crashes when detecting the charset using detectCharset from the null stream. This seems to be wrong.
Since null as a stream is supported (see @nullable in the declaration of parseInputStream, I would add this @nullable to org.jsoup.helper.DataUtil.load(InputStream, String, String) too.
Solution (not tested):
I would return null in ControllableInputStream.wrap if the stream is null.
The text was updated successfully, but these errors were encountered:
I am using jsoup 1.18.3 and noticed a ugly behaviour in comparison to jsoup 1.18.0.
I call jsoup like this:
Document doc = Jsoup.parse(stream, null, "");
It happens that the stream is null. This is detected by another part of my program and jsoup previously accepted the null stream. In
org.jsoup.helper.DataUtil.parseInputStream(ControllableInputStream, String, String, Parser)
it simply returnednew Document(baseUri)
.With one of the recent changes you wrap a
ControllableInputStream.wrap
around the stream object. Therefore the checkat the top of
org.jsoup.helper.DataUtil.parseInputStream(ControllableInputStream, String, String, Parser)
will never return a newDocument
when the stream is null. Instead it crashes when detecting the charset usingdetectCharset
from the null stream. This seems to be wrong.Since null as a stream is supported (see @nullable in the declaration of
parseInputStream
, I would add this @nullable toorg.jsoup.helper.DataUtil.load(InputStream, String, String)
too.Solution (not tested):
I would return null in
ControllableInputStream.wrap
if the stream is null.The text was updated successfully, but these errors were encountered: