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 NPE in escaping if output settings cloned twice #1964

Merged
merged 3 commits into from
Sep 12, 2023

Conversation

TalgatAkhm
Copy link
Contributor

Cloning OutputSettings leads to NPE during escaping
Code example:

    private static final Document.OutputSettings DEFAULT = new Document.OutputSettings();

    @Test
    public void test() {
        Entities.escape("text", DEFAULT.clone());
        Entities.escape("text", DEFAULT.clone());
    }

Stack:

java.lang.NullPointerException: Cannot invoke "org.jsoup.nodes.Entities$CoreCharset.ordinal()" because "charset" is null

  at org.jsoup@1.15.3/org.jsoup.nodes.Entities.canEncode(Entities.java:298)
  at org.jsoup@1.15.3/org.jsoup.nodes.Entities.escape(Entities.java:239)
  at org.jsoup@1.15.3/org.jsoup.nodes.Entities.escape(Entities.java:145)

@jhy jhy added bug Confirmed bug that we should fix fixed labels Sep 12, 2023
@jhy jhy added this to the 1.16.2 milestone Sep 12, 2023
@jhy jhy self-assigned this Sep 12, 2023
@jhy jhy merged commit 8e89706 into jhy:master Sep 12, 2023
11 checks passed
@jhy
Copy link
Owner

jhy commented Sep 12, 2023

Thanks, merged!

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 fixed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants