Skip to content

Commit 5b420f9

Browse files
subbudvkmikesamuel
andauthored
Fix : Support xxx-large and medium css font-size values. (#294)
* Fix : Support xxx-large and medium css font-size https://developer.mozilla.org/en-US/docs/Web/CSS/font-size xxx-large and medium are valid font-size values. * Test : Add tests related to xxx-large and medium font-size CSS * Added spaces between list items --------- Co-authored-by: Mike Samuel <mikesamuel@gmail.com>
1 parent 35c506c commit 5b420f9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/java/org/owasp/html/CssSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ Property forKey(String propertyName) {
383383
"bolder", "lighter");
384384
ImmutableSet<String> fontLiterals1 = ImmutableSet.of(
385385
"large", "larger", "small", "smaller", "x-large", "x-small",
386-
"xx-large", "xx-small");
386+
"xx-large", "xx-small", "xxx-large", "medium");
387387
ImmutableSet<String> fontLiterals2 = ImmutableSet.of(
388388
"caption", "icon", "menu", "message-box", "small-caption",
389389
"status-bar");

src/test/java/org/owasp/html/HtmlPolicyBuilderTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,20 @@ public static final void testTextareaIsNotTextArea() {
994994
assertEquals("x<textArea>y</textArea>", textAreaPolicy.sanitize(input));
995995
}
996996

997+
@Test
998+
public static final void testCSSFontSize() {
999+
HtmlPolicyBuilder builder = new HtmlPolicyBuilder();
1000+
PolicyFactory factory = builder.allowElements("span")
1001+
.allowAttributes("style").onElements("span").allowStyling()
1002+
.toFactory();
1003+
String toSanitizeXXXLarge = "the <span style=\"font-size:xxx-large\">large</span> formatting issue with chrome";
1004+
assertEquals(toSanitizeXXXLarge, factory.sanitize(toSanitizeXXXLarge));
1005+
1006+
String toSanitizeMedium = "the <span style=\"font-size:medium\">medium</span> formatting issue with chrome";
1007+
assertEquals(toSanitizeMedium, factory.sanitize(toSanitizeMedium));
1008+
}
1009+
1010+
9971011
private static String apply(HtmlPolicyBuilder b) {
9981012
return apply(b, EXAMPLE);
9991013
}

0 commit comments

Comments
 (0)