|
22 | 22 |
|
23 | 23 | package nu.validator.htmlparser.test;
|
24 | 24 |
|
| 25 | +import java.io.ByteArrayInputStream; |
25 | 26 | import java.io.FileInputStream;
|
26 | 27 | import java.io.IOException;
|
27 | 28 | import java.io.InputStream;
|
|
31 | 32 | import java.io.StringReader;
|
32 | 33 | import java.io.UnsupportedEncodingException;
|
33 | 34 | import java.io.Writer;
|
| 35 | +import java.nio.charset.StandardCharsets; |
| 36 | +import java.nio.file.Files; |
| 37 | +import java.nio.file.Paths; |
34 | 38 |
|
35 | 39 | import nu.validator.htmlparser.common.XmlViolationPolicy;
|
36 | 40 | import nu.validator.htmlparser.impl.ErrorReportingTokenizer;
|
@@ -217,8 +221,12 @@ private void runTestInner(String inputString, JSONArray expectedTokens,
|
217 | 221 | public static void main(String[] args) throws TokenStreamException,
|
218 | 222 | RecognitionException, SAXException, IOException {
|
219 | 223 | for (int i = 0; i < args.length; i++) {
|
220 |
| - TokenizerTester tester = new TokenizerTester(new FileInputStream( |
221 |
| - args[i])); |
| 224 | + byte[] fileBytes = Files.readAllBytes(Paths.get(args[i])); |
| 225 | + String fileContent = new String(fileBytes, StandardCharsets.UTF_8); |
| 226 | + String unescapedContent = fileContent.replace("\\\\u", "\\u"); |
| 227 | + byte[] newBytes = unescapedContent.getBytes(StandardCharsets.UTF_8); |
| 228 | + ByteArrayInputStream bais = new ByteArrayInputStream(newBytes); |
| 229 | + TokenizerTester tester = new TokenizerTester(bais); |
222 | 230 | tester.runTests();
|
223 | 231 | }
|
224 | 232 | }
|
|
0 commit comments