Skip to content
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
9 changes: 4 additions & 5 deletions src/main/java/org/owasp/html/HtmlPolicyBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -965,12 +965,11 @@ public AttributeBuilder matching(
*/
@SuppressWarnings("synthetic-access")
public HtmlPolicyBuilder globally() {
if(attributeNames.get(0).equals("style")) {
return allowStyling();
} else {
return HtmlPolicyBuilder.this.allowAttributesGlobally(
policy, attributeNames);
if (attributeNames.contains("style")) {
allowStyling();
}
return HtmlPolicyBuilder.this.allowAttributesGlobally(
policy, attributeNames);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/owasp/html/HtmlPolicyBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,12 @@ public static final void testTextareaIsNotTextArea() {
assertEquals("x<textArea>y</textArea>", textAreaPolicy.sanitize(input));
}

@Test
public static final void testHtmlPolicyBuilderDefinitionWithNoAttributesDefinedGlobally() {
// Does not crash with a runtime exception
new HtmlPolicyBuilder().allowElements().allowAttributes().globally().toFactory();
}

@Test
public static final void testCSSFontSize() {
HtmlPolicyBuilder builder = new HtmlPolicyBuilder();
Expand Down