Navigation Menu

Skip to content

Commit

Permalink
TIKA-2687 -- remove code used to generate test files
Browse files Browse the repository at this point in the history
  • Loading branch information
tballison committed Jul 13, 2018
1 parent c0fb57d commit 9b86c85
Showing 1 changed file with 0 additions and 60 deletions.
60 changes: 0 additions & 60 deletions tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java
Expand Up @@ -552,64 +552,4 @@ public void testConfigSerializationCustomStatic() throws Exception {
String content = outContent.toString(UTF_8.name());
assertFalse(content.contains("org.apache.tika.parser.executable.Executable"));
}

@Test
public void testFileNameNormalization() throws Exception {
File z = new File("C:/data/testZip_zeroByte.zip");
OutputStream os = new FileOutputStream(z);
ZipOutputStream outputStream = new ZipOutputStream(os);
ZipEntry zipEntry = new ZipEntry("dang\u0000erous.pl");
outputStream.putNextEntry(zipEntry);
byte[] bytes = "hello world1".getBytes(StandardCharsets.UTF_8);
outputStream.write(bytes, 0,bytes.length);
outputStream.closeEntry();
outputStream.flush();
outputStream.close();

z = new File("C:/data/testZip_absolutePath.zip");
os = new FileOutputStream(z);
outputStream = new ZipOutputStream(os);
zipEntry = new ZipEntry("C:/dangerous/dont/touch.pl");
outputStream.putNextEntry(zipEntry);
bytes = "hello world2".getBytes(StandardCharsets.UTF_8);
outputStream.write(bytes, 0,bytes.length);
outputStream.closeEntry();
zipEntry = new ZipEntry("/dangerous/dont/touch.pl");
outputStream.putNextEntry(zipEntry);
bytes = "hello world3".getBytes(StandardCharsets.UTF_8);
outputStream.write(bytes, 0,bytes.length);
outputStream.closeEntry();

outputStream.flush();
outputStream.close();

z = new File("C:/data/testZip_relative.zip");
os = new FileOutputStream(z);
outputStream = new ZipOutputStream(os);
zipEntry = new ZipEntry("../../../dangerous/dont/touch.pl");
outputStream.putNextEntry(zipEntry);
bytes = "hello world3".getBytes(StandardCharsets.UTF_8);
outputStream.write(bytes, 0,bytes.length);
outputStream.closeEntry();
outputStream.flush();
outputStream.close();

z = new File("C:/data/testZip_overlappingNames.zip");
os = new FileOutputStream(z);
outputStream = new ZipOutputStream(os);
zipEntry = new ZipEntry("f1.txt");
outputStream.putNextEntry(zipEntry);
bytes = "hello world4".getBytes(StandardCharsets.UTF_8);
outputStream.write(bytes, 0,bytes.length);
outputStream.closeEntry();

zipEntry = new ZipEntry("../../../f1.txt");
outputStream.putNextEntry(zipEntry);
bytes = "hello world5".getBytes(StandardCharsets.UTF_8);
outputStream.write(bytes, 0,bytes.length);
outputStream.closeEntry();

outputStream.flush();
outputStream.close();
}
}

0 comments on commit 9b86c85

Please sign in to comment.