Skip to content

Commit

Permalink
Test : Add test for duplicate noopener noreferrer when Original strin…
Browse files Browse the repository at this point in the history
…g has those attributes. (#293)
  • Loading branch information
subbudvk authored Jan 15, 2024
1 parent 3b6cc1b commit 91c5fdc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/test/java/org/owasp/html/HtmlPolicyBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,19 @@ public static final void testLinkRelsWhenRelPresent() {
));
}

@Test
public static final void testRelLinksWhenRelisPartOfData() {
PolicyFactory pf = new HtmlPolicyBuilder()
.allowElements("a")
.allowAttributes("href").onElements("a")
.allowAttributes("rel").onElements("a")
.allowAttributes("target").onElements("a")
.allowStandardUrlProtocols()
.toFactory();
String toSanitize = "<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://google.com\">test</a>";
assertTrue("Failure in testRelLinksWhenRelisPartOfData", pf.sanitize(toSanitize).equals(toSanitize));

This comment has been minimized.

Copy link
@csware

csware Jan 23, 2024

Contributor

Better write:

assertEquals(toSanitize, pf.sanitize(toSanitize));
}

@Test
public static final void testFailFastOnSpaceSeparatedStrings() {
boolean failed;
Expand Down

1 comment on commit 91c5fdc

@csware
Copy link
Contributor

@csware csware commented on 91c5fdc Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a failing test is added?

Please sign in to comment.