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

allowAttributes("style").globally() shouldn't imply allowStyling() - Regression with 2024 version #334

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,6 @@ public AttributeBuilder matching(
*/
@SuppressWarnings("synthetic-access")
public HtmlPolicyBuilder globally() {
if (attributeNames.contains("style")) {
allowStyling();
}
return HtmlPolicyBuilder.this.allowAttributesGlobally(
policy, attributeNames);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,17 +541,6 @@ public static final void testOptionAllowsText() {
pf.sanitize(input)
);
}

@Test
public static final void testStyleGlobally() {
PolicyFactory policyBuilder = new HtmlPolicyBuilder()
.allowAttributes("style").globally()
.allowElements("a", "label", "h1", "h2", "h3", "h4", "h5", "h6")
.toFactory();
String input = "<h1 style=\"color:green ;name:user ;\">This is some green text</h1>";
String want = "<h1 style=\"color:green\">This is some green text</h1>";
assertEquals(want, policyBuilder.sanitize(input));
}

static int fac(int n) {
int ifac = 1;
Expand Down
Loading