Skip to content

Commit 91c5fdc

Browse files
authored
Test : Add test for duplicate noopener noreferrer when Original string has those attributes. (#293)
1 parent 3b6cc1b commit 91c5fdc

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,19 @@ public static final void testLinkRelsWhenRelPresent() {
800800
));
801801
}
802802

803+
@Test
804+
public static final void testRelLinksWhenRelisPartOfData() {
805+
PolicyFactory pf = new HtmlPolicyBuilder()
806+
.allowElements("a")
807+
.allowAttributes("href").onElements("a")
808+
.allowAttributes("rel").onElements("a")
809+
.allowAttributes("target").onElements("a")
810+
.allowStandardUrlProtocols()
811+
.toFactory();
812+
String toSanitize = "<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://google.com\">test</a>";
813+
assertTrue("Failure in testRelLinksWhenRelisPartOfData", pf.sanitize(toSanitize).equals(toSanitize));
814+
}
815+
803816
@Test
804817
public static final void testFailFastOnSpaceSeparatedStrings() {
805818
boolean failed;

0 commit comments

Comments
 (0)