Skip to content

Fix : Support xxx-large and medium css font-size values. #294

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

Merged
merged 3 commits into from
Jan 9, 2024
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
2 changes: 1 addition & 1 deletion src/main/java/org/owasp/html/CssSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Property forKey(String propertyName) {
"bolder", "lighter");
ImmutableSet<String> fontLiterals1 = ImmutableSet.of(
"large", "larger", "small", "smaller", "x-large", "x-small",
"xx-large", "xx-small");
"xx-large", "xx-small", "xxx-large", "medium");
ImmutableSet<String> fontLiterals2 = ImmutableSet.of(
"caption", "icon", "menu", "message-box", "small-caption",
"status-bar");
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/org/owasp/html/HtmlPolicyBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,20 @@ public static final void testTextareaIsNotTextArea() {
assertEquals("x<textArea>y</textArea>", textAreaPolicy.sanitize(input));
}

@Test
public static final void testCSSFontSize() {
HtmlPolicyBuilder builder = new HtmlPolicyBuilder();
PolicyFactory factory = builder.allowElements("span")
.allowAttributes("style").onElements("span").allowStyling()
.toFactory();
String toSanitizeXXXLarge = "the <span style=\"font-size:xxx-large\">large</span> formatting issue with chrome";
assertEquals(toSanitizeXXXLarge, factory.sanitize(toSanitizeXXXLarge));

String toSanitizeMedium = "the <span style=\"font-size:medium\">medium</span> formatting issue with chrome";
assertEquals(toSanitizeMedium, factory.sanitize(toSanitizeMedium));
}


private static String apply(HtmlPolicyBuilder b) {
return apply(b, EXAMPLE);
}
Expand Down