Skip to content

Commit

Permalink
Add test for testing stack overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
spassarop committed Dec 20, 2023
1 parent 93b163b commit ddbc6fb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 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 @@ -2621,4 +2621,20 @@ public void testRawTextProcessingWhenPreservingComments() throws ScanException,
as.scan(payload, revised, AntiSamy.SAX).getCleanHTML(), not(containsString("mxss")));
}
}

@Test
public void testRegexStackOverflow() throws ScanException, PolicyException {
try {
String input =
"<img border=\"0\" width=\"320\" height=\"200\" style=\"width:3.368in;height:2.0486in\" id=\"id_123\" src=\"/url/uri\" alt=\"";
for (int i = 0; i < 2500; i++) {
input += "SampleText ";
}
input += "!\\\">";
as.scan(input, policy, AntiSamy.DOM).getCleanHTML();
as.scan(input, policy, AntiSamy.SAX).getCleanHTML();
} catch (StackOverflowError e) {
fail("Parser should not throw a stack overflow error");
}
}
}

0 comments on commit ddbc6fb

Please sign in to comment.