Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
package org.owasp.html;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
Expand All @@ -37,8 +38,6 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import org.apache.commons.codec.Resources;

/**
* Throws malformed inputs at the HTML sanitizer to try and crash it.
* This test is stochastic -- not guaranteed to pass or fail consistently.
Expand All @@ -62,9 +61,17 @@ public void text(String textChunk) { /* do nothing */ }
};

public final void testFuzzHtmlParser() throws Exception {
String html = new BufferedReader(new InputStreamReader(
Resources.getInputStream("benchmark-data/Yahoo!.html"),
StandardCharsets.UTF_8)).lines().collect(Collectors.joining());
String html;
try (InputStream resourceStream = getClass().getClassLoader()
.getResourceAsStream("benchmark-data/Yahoo!.html")) {
if (resourceStream == null) {
throw new IllegalArgumentException(
"Unable to resolve required resource: benchmark-data/Yahoo!.html");
}
html = new BufferedReader(new InputStreamReader(
resourceStream,
StandardCharsets.UTF_8)).lines().collect(Collectors.joining());
}
int length = html.length();

char[] fuzzyHtml0 = new char[length];
Expand Down
Loading