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

Missing newlines. Behavior change from 1.15.1 -> 1.15.2 #1858

Closed
sbailliez opened this issue Nov 11, 2022 · 2 comments
Closed

Missing newlines. Behavior change from 1.15.1 -> 1.15.2 #1858

sbailliez opened this issue Nov 11, 2022 · 2 comments
Milestone

Comments

@sbailliez
Copy link

Looks like there is a behavior change from 1.15.1 to 1.15.2+.

The following code fails on 1.15.2 because it is missing the newlines

    public static String sampleClean(String input) {
        String inputWithoutXmlEntities = cleanXmlEntities(value);
        String escaped = Jsoup.clean(
                input,
                "",
                Safelist.none().addTags("br"),
                new Document.OutputSettings().escapeMode(Entities.EscapeMode.xhtml));
        return Entities.unescape(escaped);
    }

    @Test
    public void sampleTest() {
        String input = "This is <a href=''>html</a> with<br>line<br>breaks";
        Assertions.assertEquals("This is html with\n<br>line\n<br>breaks", sampleClean(input));
    }
@jhy jhy closed this as completed in 29be991 Jan 5, 2023
@jhy jhy added the improvement label Jan 5, 2023
@jhy jhy added this to the 1.15.4 milestone Jan 5, 2023
@jhy
Copy link
Owner

jhy commented Jan 5, 2023

Thanks, implemented. I changed it so that the format is: Text<br>\nText (newline follows the tag, vs precedes) to look a bit more logical.

@dsw2127
Copy link

dsw2127 commented Mar 24, 2023

If the string after cleaning ends with <br>, no newline is added at all, following or preceding. Is this expected?

<div>Hi this is an <b>important</b> message.<br class='myStyle'/></div> would formerly become Hi this is an <b>important</b> message.\n<br>, now it is just Hi this is an <b>important</b> message.<br> no newlines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants