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

NullPointer Exception on try to parse next fragment (trying to put h2 inside p) #1601

Closed
kokorins opened this issue Jul 31, 2021 · 1 comment
Assignees
Labels
bug Confirmed bug that we should fix
Milestone

Comments

@kokorins
Copy link

kokorins commented Jul 31, 2021

I understand that headers shouldn't be a part of paragraph, but still it should be more explicit in context of code bellow.
If Element is replaced with div or null everything is perfect

Sorry for Kotlin, hope it still readable.

        val bareFragment = "<h2> text </h2>"
        Document("").parser().parseFragmentInput(bareFragment, Element("p"), "")

output:

java.lang.NullPointerException
	at org.jsoup.parser.HtmlTreeBuilderState$7.inBodyStartTag(HtmlTreeBuilderState.java:545)
	at org.jsoup.parser.HtmlTreeBuilderState$7.process(HtmlTreeBuilderState.java:286)
	at org.jsoup.parser.HtmlTreeBuilder.process(HtmlTreeBuilder.java:149)
	at org.jsoup.parser.TreeBuilder.runParser(TreeBuilder.java:76)
	at org.jsoup.parser.HtmlTreeBuilder.parseFragment(HtmlTreeBuilder.java:133)
	at org.jsoup.parser.Parser.parseFragmentInput(Parser.java:53)
@jhy jhy self-assigned this Aug 4, 2021
@jhy jhy added the bug Confirmed bug that we should fix label Aug 4, 2021
@jhy jhy added this to the 1.14.2 milestone Aug 4, 2021
@jhy jhy closed this as completed in dd2536b Aug 4, 2021
@jhy
Copy link
Owner

jhy commented Aug 4, 2021

Thanks, fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug that we should fix
Projects
None yet
Development

No branches or pull requests

2 participants