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

Element.html throws Null Pointer #1603

Closed
thomashcampbell opened this issue Aug 1, 2021 · 4 comments
Closed

Element.html throws Null Pointer #1603

thomashcampbell opened this issue Aug 1, 2021 · 4 comments
Assignees
Labels
bug Confirmed bug that we should fix
Milestone

Comments

@thomashcampbell
Copy link

This worked in Version 1.12.1 but is broken in 1.14.1

    **Element element =
            new Element(Tr_Tag);

    element.html("<tr><td colspan='5' class='bold'>Specials</td></tr>");**

now throws

java.lang.NullPointerException: Cannot invoke "org.jsoup.nodes.Element.normalName()" because the return value of "org.jsoup.parser.HtmlTreeBuilder.currentElement()" is null

at org.jsoup.parser.HtmlTreeBuilderState$9.process(HtmlTreeBuilderState.java:984)
at org.jsoup.parser.HtmlTreeBuilder.process(HtmlTreeBuilder.java:154)
at org.jsoup.parser.HtmlTreeBuilderState$13.anythingElse(HtmlTreeBuilderState.java:1186)
at org.jsoup.parser.HtmlTreeBuilderState$13.process(HtmlTreeBuilderState.java:1169)
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)
at org.jsoup.nodes.Element.append(Element.java:679)
at org.jsoup.nodes.Element.html(Element.java:1620)
@thomashcampbell
Copy link
Author

Checked 1.13.1 and it worked there as well.

@kokorins
Copy link

kokorins commented Aug 1, 2021

One more similar example:

        val bareFragment = """
<table>
<tr><td></td></tr>
</table>
        """.trimIndent()
        Document("").parser().parseFragmentInput(bareFragment, Element("p"), "")

output:

java.lang.NullPointerException
	at org.jsoup.parser.HtmlTreeBuilderState$9.process(HtmlTreeBuilderState.java:984)
	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 this to the 1.14.2 milestone Aug 4, 2021
@jhy jhy added the bug Confirmed bug that we should fix label Aug 4, 2021
@jhy jhy closed this as completed in 26d3c14 Aug 4, 2021
@jhy
Copy link
Owner

jhy commented Aug 4, 2021

Thanks, fixed!

@thomashcampbell
Copy link
Author

Confirmed in 1.14.2. Thank you for the quick turnaround!

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

3 participants