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

html-filter: allow summary and details html element. Thanks to naejadu #832

Merged
merged 3 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/freenet/client/filter/HTMLFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,9 @@ private static Map<String, TagVerifier> getAllowedTagVerifiers()
"article",
"section",
"hgroup",
"wbr"};
"wbr",
"summary",
"details"};
for (String x: group2)
allowedTagsVerifiers.put(
x,
Expand Down
19 changes: 11 additions & 8 deletions test/freenet/client/filter/ContentFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ public class ContentFilterTest {

private static final String SPAN_WITH_STYLE = "<span style=\"font-family: verdana, sans-serif; color: red;\">";

private static final String BASE_HREF = "<base href=\"/" + BASE_KEY + "\">";
private static final String BAD_BASE_HREF = "<base href=\"/\">";
private static final String BAD_BASE_HREF2 = "<base href=\"//www.google.com\">";
private static final String BAD_BASE_HREF3 = "<base>";
private static final String BAD_BASE_HREF4 = "<base id=\"blah\">";
private static final String BAD_BASE_HREF5 = "<base href=\"http://www.google.com/\">";
private static final String DELETED_BASE_HREF = "<!-- deleted invalid base href -->";
private static final String HTML5_TAGS = "<article><details><summary>TLDR</summary><center>Too Long Di<wbr />dn’t Read</center></details></article>";

private static final String BASE_HREF = "<base href=\"/"+BASE_KEY+"\">";
private static final String BAD_BASE_HREF = "<base href=\"/\">";
private static final String BAD_BASE_HREF2 = "<base href=\"//www.google.com\">";
private static final String BAD_BASE_HREF3 = "<base>";
private static final String BAD_BASE_HREF4 = "<base id=\"blah\">";
private static final String BAD_BASE_HREF5 = "<base href=\"http://www.google.com/\">";
private static final String DELETED_BASE_HREF = "<!-- deleted invalid base href -->";

// From CSS spec

Expand Down Expand Up @@ -182,7 +184,8 @@ public void testHTMLFilter() throws Exception {

assertEquals(CSS_SPEC_EXAMPLE1, htmlFilter(CSS_SPEC_EXAMPLE1));

assertEquals(SPAN_WITH_STYLE, htmlFilter(SPAN_WITH_STYLE));
assertEquals(SPAN_WITH_STYLE, HTMLFilter(SPAN_WITH_STYLE));
assertEquals(HTML5_TAGS, HTMLFilter(HTML5_TAGS));

assertEquals(BASE_HREF, htmlFilter(BASE_HREF));
assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF));
Expand Down