Skip to content

Commit

Permalink
add test for issue nahsra#453
Browse files Browse the repository at this point in the history
use 4.2.0-SNAPSHOT
  • Loading branch information
rbri committed May 27, 2024
1 parent 1afa168 commit 2eee0b3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<dependency>
<groupId>org.htmlunit</groupId>
<artifactId>neko-htmlunit</artifactId>
<version>4.1.0</version>
<version>4.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
35 changes: 35 additions & 0 deletions src/test/java/org/owasp/validator/html/test/AntiSamyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2666,4 +2666,39 @@ public void testBangCommentsWhenPreservingComments() throws ScanException, Polic
.getCleanHTML(),
not(containsString("mxss")));
}

static final String test453 =
"<html lang=\"en\">\n"
+ "<head>\n"
+ "</head>\n"
+ "<table>\n"
+ "<SELECT NAME=\"Lang\">\n"
+ "<OPTION VALUE=\"da\">Dansk</OPTION>\n"
+ "<OPTION VALUE=\"en\" selected=selected>English</OPTION>\n"
+ "</SELECT>\n"
+ "</table>\n"
+ "</html>";

@Test
public void testGithubIssue453() throws ScanException, PolicyException {
String cleaned = as.scan(test453, policy, AntiSamy.SAX).getCleanHTML();
cleaned = cleaned.replaceAll("\r?\n", "");
cleaned = cleaned.replaceAll("\\s\\s+", " ");

assertThat(
cleaned,
containsString("<body> <table> "
+ "<select name=\"Lang\"> "
+ "<option value=\"da\">Dansk</option> "));

cleaned = as.scan(test453, policy, AntiSamy.DOM).getCleanHTML();
cleaned = cleaned.replaceAll("\r?\n", "");
cleaned = cleaned.replaceAll("\\s\\s+", " ");

assertThat(
cleaned,
containsString("<body> <table> "
+ "<select name=\"Lang\"> "
+ "<option value=\"da\">Dansk</option> "));
}
}

0 comments on commit 2eee0b3

Please sign in to comment.