File tree Expand file tree Collapse file tree
owasp-java-html-sanitizer/src/test/java/org/owasp/html Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929package org .owasp .html ;
3030
3131import java .io .BufferedReader ;
32+ import java .io .InputStream ;
3233import java .io .InputStreamReader ;
3334import java .nio .charset .StandardCharsets ;
3435import java .util .List ;
3738import java .util .concurrent .TimeUnit ;
3839import java .util .stream .Collectors ;
3940
40- import org .apache .commons .codec .Resources ;
41-
4241/**
4342 * Throws malformed inputs at the HTML sanitizer to try and crash it.
4443 * This test is stochastic -- not guaranteed to pass or fail consistently.
@@ -62,9 +61,17 @@ public void text(String textChunk) { /* do nothing */ }
6261 };
6362
6463 public final void testFuzzHtmlParser () throws Exception {
65- String html = new BufferedReader (new InputStreamReader (
66- Resources .getInputStream ("benchmark-data/Yahoo!.html" ),
67- StandardCharsets .UTF_8 )).lines ().collect (Collectors .joining ());
64+ String html ;
65+ try (InputStream resourceStream = getClass ().getClassLoader ()
66+ .getResourceAsStream ("benchmark-data/Yahoo!.html" )) {
67+ if (resourceStream == null ) {
68+ throw new IllegalArgumentException (
69+ "Unable to resolve required resource: benchmark-data/Yahoo!.html" );
70+ }
71+ html = new BufferedReader (new InputStreamReader (
72+ resourceStream ,
73+ StandardCharsets .UTF_8 )).lines ().collect (Collectors .joining ());
74+ }
6875 int length = html .length ();
6976
7077 char [] fuzzyHtml0 = new char [length ];
You can’t perform that action at this time.
0 commit comments