Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Allow HTML5 details tag in Safelist.relaxed #1767

Open
dschulten opened this issue May 12, 2022 · 1 comment
Open

Allow HTML5 details tag in Safelist.relaxed #1767

dschulten opened this issue May 12, 2022 · 1 comment

Comments

@dschulten
Copy link

Would it be possible to include the HTML5 Tags details and summary in Safelist.relaxed?

https://developer.mozilla.org/de/docs/Web/HTML/Element/details

Or are there reasons why those two tags cannot be considered safe?

@jeffthomasweb
Copy link

Apologies if this is already widely known, but if anyone would like to add their own safe HTML tags for current Jsoup versions, Safelist.addTags("stringTag1","stringTag2") is available. I've included an example below. https://github.com/jhy/jsoup/blob/master/src/main/java/org/jsoup/safety/Safelist.java#L222

String cleanRelaxedIncludeHtmlDetailsSummary() throws IOException {
        Safelist listOfSafeHtml = Safelist.relaxed().addTags("details","summary");
        String htmlWithDetailsSummary = "<details><summary>Details</summary>Something small enough to escape casual notice.</details>";
        String afterCleanedRelaxedHtml = Jsoup.clean(htmlWithDetailsSummary, listOfSafeHtml);

        return afterCleanedRelaxedHtml;
    }

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

No branches or pull requests

2 participants