Skip to content

Commit e4da37e

Browse files
committed
TIKA-4518 -- escape quotes in filenames for better cross platform robustness
1 parent 17826b5 commit e4da37e

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

tika-app/src/test/java/org/apache/tika/cli/TikaCLITest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,10 @@ public void testPSTRUnpack() throws Exception {
299299
"testPST.pst-embed/00000008-First email.msg",
300300
"testPST.pst-embed/00000004-[jira] [Resolved] (TIKA-1249) Vcard files detection.msg",
301301
"testPST.pst-embed/00000003-Feature Generators.msg",
302-
"testPST.pst-embed/00000002-putstatic\".msg",
302+
"testPST.pst-embed/00000002-putstatic%22.msg",
303303
"testPST.pst-embed/00000005-[jira] [Commented] (TIKA-1250) Process loops infintely processing a CHM file.msg",
304304
"testPST.pst-embed/00000009-attachment.docx",
305-
"testPST.pst-embed/00000006-[WEBINAR] - \"Introducing Couchbase Server 2.5\".msg"};
305+
"testPST.pst-embed/00000006-[WEBINAR] - %22Introducing Couchbase Server 2.5%22.msg"};
306306
testRecursiveUnpack("testPST.pst", expectedChildren, 2);
307307
try (Reader reader = Files.newBufferedReader(extractDir.resolve("testPST.pst.json"))) {
308308
List<Metadata> metadataList = JsonMetadataList.fromJson(reader);

tika-core/src/main/java/org/apache/tika/io/FilenameUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class FilenameUtils {
3939
public final static char[] RESERVED_FILENAME_CHARACTERS =
4040
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
4141
0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A,
42-
0x1B, 0x1C, 0x1D, 0x1E, 0x1F, '?', ':', '*', '<', '>', '|'};
42+
0x1B, 0x1C, 0x1D, 0x1E, 0x1F, '?', ':', '*', '<', '>', '|', '"', '\''};
4343

4444
private final static HashSet<Character> RESERVED = new HashSet<>(38);
4545

tika-core/src/test/java/org/apache/tika/io/FilenameUtilsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void testEmbeddedFileNames() throws Exception {
152152
assertEquals("_the quick brown fox.xlsx", sanitizeFilename("C:\\a/b/c/..the quick brown fox.xlsx"));
153153
assertEquals("_the quick brown fox.xlsx", sanitizeFilename("~/a/b/c/.the quick brown fox.xlsx"));
154154
assertEquals("the quick%3Ebrown fox.xlsx", sanitizeFilename("the quick>brown fox.xlsx"));
155-
assertEquals("the quick\"brown fox.xlsx", sanitizeFilename("the quick\"brown fox.xlsx"));
155+
assertEquals("the quick%22brown fox.xlsx", sanitizeFilename("the quick\"brown fox.xlsx"));
156156
assertEquals("the quick brown fox.xlsx", sanitizeFilename("\"the quick brown fox.xlsx\""));
157157

158158
assertEquals("_.docx", sanitizeFilename("..................docx"));

0 commit comments

Comments
 (0)