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

add test for issue #453 - fix is done in neko #454

Merged
merged 6 commits into from
Jun 6, 2024
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
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.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
36 changes: 36 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,40 @@ public void testBangCommentsWhenPreservingComments() throws ScanException, Polic
.getCleanHTML(),
not(containsString("mxss")));
}

@Test
public void testGithubIssue453() throws ScanException, PolicyException {
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>";
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> "));
}
}