aboutsummaryrefslogtreecommitdiffstats
path: root/poi-scratchpad
diff options
context:
space:
mode:
authorTim Allison <tallison@apache.org>2023-09-20 20:32:59 +0000
committerTim Allison <tallison@apache.org>2023-09-20 20:32:59 +0000
commit99117381e59d9a7f2abe27784009358c672c0ae3 (patch)
tree190b7ef61d91f9579bd7605d1a2c45cf142ea674 /poi-scratchpad
parentce919673c4e935e8c756c91938f973d5c9a23ddb (diff)
downloadpoi-99117381e59d9a7f2abe27784009358c672c0ae3.tar.gz
poi-99117381e59d9a7f2abe27784009358c672c0ae3.zip
Bug47950 -- make stream/directory name lookup in OLE2 case insensitive
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1912438 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-scratchpad')
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java12
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java6
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java4
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java12
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java6
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java8
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToTextConverter.java2
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/ObjectPoolImpl.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java10
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestExtractor.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestTextRunReWrite.java8
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java2
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java46
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFDocFixture.java4
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hwpf/extractor/TestWordExtractor.java24
19 files changed, 86 insertions, 72 deletions
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java b/poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
index 64c2c6fce0..5bd8783294 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/extractor/ole2/OLE2ScratchpadExtractorFactory.java
@@ -108,7 +108,7 @@ public class OLE2ScratchpadExtractorFactory implements ExtractorProvider {
final String oldPW = Biff8EncryptionKey.getCurrentUserPassword();
try {
Biff8EncryptionKey.setCurrentUserPassword(password);
- if (poifsDir.hasEntry("WordDocument")) {
+ if (poifsDir.hasEntryCaseInsensitive("WordDocument")) {
// Old or new style word document?
try {
return new WordExtractor(poifsDir);
@@ -117,20 +117,20 @@ public class OLE2ScratchpadExtractorFactory implements ExtractorProvider {
}
}
- if (poifsDir.hasEntry(HSLFSlideShow.POWERPOINT_DOCUMENT) || poifsDir.hasEntry(HSLFSlideShow.PP97_DOCUMENT)) {
+ if (poifsDir.hasEntryCaseInsensitive(HSLFSlideShow.POWERPOINT_DOCUMENT) || poifsDir.hasEntryCaseInsensitive(HSLFSlideShow.PP97_DOCUMENT)) {
return new SlideShowExtractor<>((HSLFSlideShow)SlideShowFactory.create(poifsDir));
}
- if (poifsDir.hasEntry("VisioDocument")) {
+ if (poifsDir.hasEntryCaseInsensitive("VisioDocument")) {
return new VisioTextExtractor(poifsDir);
}
- if (poifsDir.hasEntry("Quill")) {
+ if (poifsDir.hasEntryCaseInsensitive("Quill")) {
return new PublisherTextExtractor(poifsDir);
}
for (String entryName : OUTLOOK_ENTRY_NAMES) {
- if (poifsDir.hasEntry(entryName)) {
+ if (poifsDir.hasEntryCaseInsensitive(entryName)) {
return new OutlookTextExtractor(poifsDir);
}
}
@@ -168,7 +168,7 @@ public class OLE2ScratchpadExtractorFactory implements ExtractorProvider {
} else if (ext instanceof WordExtractor) {
// These are in ObjectPool -> _... under the root
try {
- DirectoryEntry op = (DirectoryEntry) root.getEntry("ObjectPool");
+ DirectoryEntry op = (DirectoryEntry) root.getEntryCaseInsensitive("ObjectPool");
StreamSupport.stream(op.spliterator(), false)
.filter(entry -> entry.getName().startsWith("_"))
.forEach(dirs::add);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java
index 4fccf48565..5154df9849 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/dev/HPBFDumper.java
@@ -103,7 +103,7 @@ public final class HPBFDumper {
*/
public void dumpEscher() throws IOException {
DirectoryNode escherDir = (DirectoryNode)
- fs.getRoot().getEntry("Escher");
+ fs.getRoot().getEntryCaseInsensitive("Escher");
dumpEscherStm(escherDir);
dumpEscherDelayStm(escherDir);
@@ -343,9 +343,9 @@ public final class HPBFDumper {
public void dumpQuill() throws IOException {
DirectoryNode quillDir = (DirectoryNode)
- fs.getRoot().getEntry("Quill");
+ fs.getRoot().getEntryCaseInsensitive("Quill");
DirectoryNode quillSubDir = (DirectoryNode)
- quillDir.getEntry("QuillSub");
+ quillDir.getEntryCaseInsensitive("QuillSub");
dump001CompObj(quillSubDir);
dumpCONTENTSraw(quillSubDir);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java
index c3d44099de..8016e9b718 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hpbf/model/HPBFPart.java
@@ -44,7 +44,7 @@ public abstract class HPBFPart {
DirectoryNode dir = getDir(baseDir, path);
String name = path[path.length-1];
- if (!dir.hasEntry(name)) {
+ if (!dir.hasEntryCaseInsensitive(name)) {
throw new IllegalArgumentException("File invalid - failed to find document entry '" + name + "'");
}
@@ -78,7 +78,7 @@ public abstract class HPBFPart {
DirectoryNode dir = baseDir;
for(int i=0; i<path.length-1; i++) {
try {
- dir = (DirectoryNode)dir.getEntry(path[i]);
+ dir = (DirectoryNode)dir.getEntryCaseInsensitive(path[i]);
} catch(FileNotFoundException e) {
dir.createDirectory(path[i]);
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
index f6b523fcc3..fff6523b85 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
@@ -63,7 +63,7 @@ public final class PPTXMLDump {
private static byte[] readEntry(POIFSFileSystem fs, String entry)
throws IOException {
DirectoryNode dn = fs.getRoot();
- if (!dn.hasEntry(entry)) {
+ if (!dn.hasEntryCaseInsensitive(entry)) {
return null;
}
try (InputStream is = dn.createDocumentInputStream(entry);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java
index 3bdcee13b9..8f6cdd9aa2 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/CurrentUserAtom.java
@@ -140,7 +140,7 @@ public class CurrentUserAtom {
// See how long it is. If it's under 28 bytes long, we can't
// read it
if(_contents.length < 28) {
- boolean isPP95 = dir.hasEntry(PP95_DOCUMENT);
+ boolean isPP95 = dir.hasEntryCaseInsensitive(PP95_DOCUMENT);
// PPT95 has 4 byte size, then data
if (!isPP95 && _contents.length >= 4) {
int size = LittleEndian.getInt(_contents);
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
index 8fd7a1d40a..9b0d96cdfb 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
@@ -1047,7 +1047,7 @@ public final class HSLFSlideShow extends POIDocument implements SlideShow<HSLFSh
Map<String,ClassID> olemap = getOleMap();
ClassID classID = null;
for (Map.Entry<String,ClassID> entry : olemap.entrySet()) {
- if (root.hasEntry(entry.getKey())) {
+ if (root.hasEntryCaseInsensitive(entry.getKey())) {
classID = entry.getValue();
break;
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
index 9f55214ee5..53bf44300b 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
@@ -197,10 +197,10 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
private static DirectoryNode handleDualStorage(DirectoryNode dir) throws IOException {
// when there's a dual storage entry, use it, as the outer document can't be read quite probably ...
- if (!dir.hasEntry(PP97_DOCUMENT)) {
+ if (!dir.hasEntryCaseInsensitive(PP97_DOCUMENT)) {
return dir;
}
- return (DirectoryNode) dir.getEntry(PP97_DOCUMENT);
+ return (DirectoryNode) dir.getEntryCaseInsensitive(PP97_DOCUMENT);
}
/**
@@ -226,12 +226,12 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
private void readPowerPointStream() throws IOException {
final DirectoryNode dir = getDirectory();
- if (!dir.hasEntry(POWERPOINT_DOCUMENT) && dir.hasEntry(PP95_DOCUMENT)) {
+ if (!dir.hasEntryCaseInsensitive(POWERPOINT_DOCUMENT) && dir.hasEntryCaseInsensitive(PP95_DOCUMENT)) {
throw new OldPowerPointFormatException("You seem to have supplied a PowerPoint95 file, which isn't supported");
}
// Get the main document stream
- final Entry entry = dir.getEntry(POWERPOINT_DOCUMENT);
+ final Entry entry = dir.getEntryCaseInsensitive(POWERPOINT_DOCUMENT);
if (!(entry instanceof DocumentEntry)) {
throw new IllegalArgumentException("Had unexpected type of entry for name: " + POWERPOINT_DOCUMENT + ": " + entry.getClass());
}
@@ -399,12 +399,12 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
private void readPictures() throws IOException {
// if the presentation doesn't contain pictures, will use an empty collection instead
- if (!getDirectory().hasEntry("Pictures")) {
+ if (!getDirectory().hasEntryCaseInsensitive("Pictures")) {
_pictures = new ArrayList<>();
return;
}
- final Entry en = getDirectory().getEntry("Pictures");
+ final Entry en = getDirectory().getEntryCaseInsensitive("Pictures");
if (!(en instanceof DocumentEntry)) {
throw new IllegalArgumentException("Had unexpected type of entry for name: Pictures: " + en.getClass());
}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
index 53c37ffe8f..12577ea186 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocument.java
@@ -261,7 +261,7 @@ public final class HWPFDocument extends HWPFDocumentCore {
String name = (_fib.getFibBase().isFWhichTblStm()) ? STREAM_TABLE_1 : STREAM_TABLE_0;
// Grab the table stream.
- if (!directory.hasEntry(name)) {
+ if (!directory.hasEntryCaseInsensitive(name)) {
throw new IllegalStateException("Table Stream '" + name + "' wasn't found - Either the document is corrupt, or is Word95 (or earlier)");
}
@@ -271,7 +271,7 @@ public final class HWPFDocument extends HWPFDocumentCore {
_fib.fillVariableFields(_mainStream, _tableStream);
// read in the data stream.
- _dataStream = directory.hasEntry(STREAM_DATA) ? getDocumentEntryBytes(STREAM_DATA, 0, Integer.MAX_VALUE) : new byte[0];
+ _dataStream = directory.hasEntryCaseInsensitive(STREAM_DATA) ? getDocumentEntryBytes(STREAM_DATA, 0, Integer.MAX_VALUE) : new byte[0];
// Get the cp of the start of text in the main stream
// The latest spec doc says this is always zero!
@@ -1033,4 +1033,4 @@ public final class HWPFDocument extends HWPFDocumentCore {
Range r = new Range(start, start + length, this);
r.delete();
}
-} \ No newline at end of file
+}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java
index 22bf28eab7..86f9956824 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/HWPFDocumentCore.java
@@ -185,8 +185,8 @@ public abstract class HWPFDocumentCore extends POIDocument {
_fib = new FileInformationBlock(_mainStream);
DirectoryEntry objectPoolEntry = null;
- if (directory.hasEntry(STREAM_OBJECT_POOL)) {
- final Entry entry = directory.getEntry(STREAM_OBJECT_POOL);
+ if (directory.hasEntryCaseInsensitive(STREAM_OBJECT_POOL)) {
+ final Entry entry = directory.getEntryCaseInsensitive(STREAM_OBJECT_POOL);
if (!(entry instanceof DirectoryEntry)) {
throw new IllegalArgumentException("Had unexpected type of entry for name: " + STREAM_OBJECT_POOL + ": " + entry.getClass());
}
@@ -341,7 +341,7 @@ public abstract class HWPFDocumentCore extends POIDocument {
*/
protected byte[] getDocumentEntryBytes(String name, int encryptionOffset, final int len) throws IOException {
DirectoryNode dir = getDirectory();
- final Entry entry = dir.getEntry(name);
+ final Entry entry = dir.getEntryCaseInsensitive(name);
if (!(entry instanceof DocumentEntry)) {
throw new IllegalArgumentException("Had unexpected type of entry for name: " + name + ": " + entry);
}
@@ -368,4 +368,4 @@ public abstract class HWPFDocumentCore extends POIDocument {
}
return new SequenceInputStream(new ByteArrayInputStream(plain), cis);
}
-} \ No newline at end of file
+}
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToTextConverter.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToTextConverter.java
index 915abe819a..58f529a3c9 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToTextConverter.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToTextConverter.java
@@ -332,7 +332,7 @@ public class WordToTextConverter extends AbstractWordConverter {
* even if there is no ExtractorFactory in classpath, still support
* included Word's objects
*/
- if ( directoryNode.hasEntry( "WordDocument" ) )
+ if ( directoryNode.hasEntryCaseInsensitive( "WordDocument" ) )
{
String text = WordToTextConverter.getText( (DirectoryNode) entry );
block.appendChild( textDocumentFacade
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/ObjectPoolImpl.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/ObjectPoolImpl.java
index c672134ec4..644814d340 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/ObjectPoolImpl.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/usermodel/ObjectPoolImpl.java
@@ -42,7 +42,7 @@ public class ObjectPoolImpl implements ObjectsPool
try
{
- return _objectPool.getEntry( objId );
+ return _objectPool.getEntryCaseInsensitive( objId );
}
catch ( FileNotFoundException exc )
{
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java
index 48e2666aa1..0606c28950 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/TestReWrite.java
@@ -92,20 +92,20 @@ public final class TestReWrite {
assertSlideShowWritesOutTheSame(hssC, pfsC);
// Currently has a Macros stream
- assertNotNull(pfsC.getRoot().getEntry("Macros"));
+ assertNotNull(pfsC.getRoot().getEntryCaseInsensitive("Macros"));
// Write out normally, will loose the macro stream
UnsynchronizedByteArrayOutputStream baos = UnsynchronizedByteArrayOutputStream.builder().get();
hssC.write(baos);
try (POIFSFileSystem pfsNew = new POIFSFileSystem(baos.toInputStream())) {
- assertFalse(pfsNew.getRoot().hasEntry("Macros"));
+ assertFalse(pfsNew.getRoot().hasEntryCaseInsensitive("Macros"));
}
// But if we write out with nodes preserved, will be there
baos.reset();
hssC.write(baos, true);
try (POIFSFileSystem pfsNew = new POIFSFileSystem(baos.toInputStream())) {
- assertTrue(pfsNew.getRoot().hasEntry("Macros"));
+ assertTrue(pfsNew.getRoot().hasEntryCaseInsensitive("Macros"));
}
}
}
@@ -145,8 +145,8 @@ public final class TestReWrite {
private void assertSame(POIFSFileSystem origPFS, POIFSFileSystem newPFS) throws IOException {
// Check that the "PowerPoint Document" sections have the same size
- DocumentEntry oProps = (DocumentEntry) origPFS.getRoot().getEntry(POWERPOINT_DOCUMENT);
- DocumentEntry nProps = (DocumentEntry) newPFS.getRoot().getEntry(POWERPOINT_DOCUMENT);
+ DocumentEntry oProps = (DocumentEntry) origPFS.getRoot().getEntryCaseInsensitive(POWERPOINT_DOCUMENT);
+ DocumentEntry nProps = (DocumentEntry) newPFS.getRoot().getEntryCaseInsensitive(POWERPOINT_DOCUMENT);
assertEquals(oProps.getSize(), nProps.getSize());
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestExtractor.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestExtractor.java
index 6b8a08ff2d..4d70257650 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestExtractor.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/extractor/TestExtractor.java
@@ -185,8 +185,8 @@ public final class TestExtractor {
};
for (int i=0; i<TEST_SET.length; i+=2) {
- DirectoryNode dir = (DirectoryNode)root.getEntry(TEST_SET[i]);
- assertTrue(dir.hasEntry(HSLFSlideShow.POWERPOINT_DOCUMENT));
+ DirectoryNode dir = (DirectoryNode)root.getEntryCaseInsensitive(TEST_SET[i]);
+ assertTrue(dir.hasEntryCaseInsensitive(HSLFSlideShow.POWERPOINT_DOCUMENT));
try (final SlideShow<?,?> ppt = SlideShowFactory.create(dir);
final SlideShowExtractor<?,?> ppe = new SlideShowExtractor<>(ppt)) {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestTextRunReWrite.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestTextRunReWrite.java
index b38ae3ba51..658e2df370 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestTextRunReWrite.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/model/TestTextRunReWrite.java
@@ -79,8 +79,8 @@ public final class TestTextRunReWrite {
// Check that the "PowerPoint Document" sections have the same size
DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
- DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ DocumentEntry oProps = (DocumentEntry) oDir.getEntryCaseInsensitive(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntryCaseInsensitive(HSLFSlideShow.POWERPOINT_DOCUMENT);
assertEquals(oProps.getSize(), nProps.getSize());
// Check that they contain the same data
@@ -130,8 +130,8 @@ public final class TestTextRunReWrite {
// Check that the "PowerPoint Document" sections have the same size
DirectoryNode oDir = ppt1.getSlideShowImpl().getDirectory();
- DocumentEntry oProps = (DocumentEntry) oDir.getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
- DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntry(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ DocumentEntry oProps = (DocumentEntry) oDir.getEntryCaseInsensitive(HSLFSlideShow.POWERPOINT_DOCUMENT);
+ DocumentEntry nProps = (DocumentEntry) npfs.getRoot().getEntryCaseInsensitive(HSLFSlideShow.POWERPOINT_DOCUMENT);
assertEquals(oProps.getSize(), nProps.getSize());
// Check that they contain the same data
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java
index a1ee955fd3..780e36500a 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestCurrentUserAtom.java
@@ -76,7 +76,7 @@ public final class TestCurrentUserAtom {
// Get raw contents from a known file
byte[] contents;
try (POIFSFileSystem fs = new POIFSFileSystem(_slTests.getFile(normalFile))) {
- DocumentEntry docProps = (DocumentEntry) fs.getRoot().getEntry("Current User");
+ DocumentEntry docProps = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("Current User");
contents = new byte[docProps.getSize()];
try (InputStream in = fs.getRoot().createDocumentInputStream("Current User")) {
in.read(contents);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java
index 46d607e729..8563bf7c5e 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExOleObjStg.java
@@ -62,7 +62,7 @@ public final class TestExOleObjStg {
assertEquals(len, oledata.length);
try (POIFSFileSystem fs = new POIFSFileSystem(record.getData())) {
- DocumentEntry doc = (DocumentEntry) fs.getRoot().getEntry("Contents");
+ DocumentEntry doc = (DocumentEntry) fs.getRoot().getEntryCaseInsensitive("Contents");
assertNotNull(doc);
}
}
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
index f93ff19f0f..17d58effea 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
@@ -56,13 +56,13 @@ public final class TestPOIFSChunkParser {
void testFindsCore() throws IOException, ChunkNotFoundException {
try (POIFSFileSystem simple = new POIFSFileSystem(samples.getFile("quick.msg"), true)) {
- // Check a few core things are present
- simple.getRoot().getEntry(
- (new StringChunk(MAPIProperty.SUBJECT.id, Types.ASCII_STRING)).getEntryName()
- );
- simple.getRoot().getEntry(
- (new StringChunk(MAPIProperty.SENDER_NAME.id, Types.ASCII_STRING)).getEntryName()
- );
+ // Check a few core things are present
+ simple.getRoot().getEntryCaseInsensitive(
+ (new StringChunk(MAPIProperty.SUBJECT.id, Types.ASCII_STRING)).getEntryName()
+ );
+ simple.getRoot().getEntryCaseInsensitive(
+ (new StringChunk(MAPIProperty.SENDER_NAME.id, Types.ASCII_STRING)).getEntryName()
+ );
// Now load the file
try (MAPIMessage msg = new MAPIMessage(simple)) {
@@ -82,7 +82,7 @@ public final class TestPOIFSChunkParser {
void testFindsRecips() throws IOException, ChunkNotFoundException {
try (POIFSFileSystem simple = new POIFSFileSystem(samples.getFile("quick.msg"), true)) {
- simple.getRoot().getEntry("__recip_version1.0_#00000000");
+ simple.getRoot().getEntryCaseInsensitive("__recip_version1.0_#00000000");
ChunkGroup[] groups = POIFSChunkParser.parse(simple.getRoot());
assertEquals(3, groups.length);
@@ -136,12 +136,12 @@ public final class TestPOIFSChunkParser {
void testFindsMultipleRecipients() throws IOException, ChunkNotFoundException {
try (POIFSFileSystem multiple = new POIFSFileSystem(samples.getFile("example_received_unicode.msg"), true)) {
- multiple.getRoot().getEntry("__recip_version1.0_#00000000");
- multiple.getRoot().getEntry("__recip_version1.0_#00000001");
- multiple.getRoot().getEntry("__recip_version1.0_#00000002");
- multiple.getRoot().getEntry("__recip_version1.0_#00000003");
- multiple.getRoot().getEntry("__recip_version1.0_#00000004");
- multiple.getRoot().getEntry("__recip_version1.0_#00000005");
+ multiple.getRoot().getEntryCaseInsensitive("__recip_version1.0_#00000000");
+ multiple.getRoot().getEntryCaseInsensitive("__recip_version1.0_#00000001");
+ multiple.getRoot().getEntryCaseInsensitive("__recip_version1.0_#00000002");
+ multiple.getRoot().getEntryCaseInsensitive("__recip_version1.0_#00000003");
+ multiple.getRoot().getEntryCaseInsensitive("__recip_version1.0_#00000004");
+ multiple.getRoot().getEntryCaseInsensitive("__recip_version1.0_#00000005");
ChunkGroup[] groups = POIFSChunkParser.parse(multiple.getRoot());
assertEquals(9, groups.length);
@@ -228,7 +228,7 @@ public final class TestPOIFSChunkParser {
void testFindsNameId() throws IOException {
try (POIFSFileSystem simple = new POIFSFileSystem(samples.getFile("quick.msg"), true)) {
- simple.getRoot().getEntry("__nameid_version1.0");
+ simple.getRoot().getEntryCaseInsensitive("__nameid_version1.0");
ChunkGroup[] groups = POIFSChunkParser.parse(simple.getRoot());
assertEquals(3, groups.length);
@@ -253,10 +253,11 @@ public final class TestPOIFSChunkParser {
POIFSFileSystem without = new POIFSFileSystem(samples.getFile("quick.msg"), true)) {
AttachmentChunks attachment;
- // Check raw details on the one with
- with.getRoot().getEntry("__attach_version1.0_#00000000");
- with.getRoot().getEntry("__attach_version1.0_#00000001");
- POIFSChunkParser.parse(with.getRoot());
+
+ // Check raw details on the one with
+ with.getRoot().getEntryCaseInsensitive("__attach_version1.0_#00000000");
+ with.getRoot().getEntryCaseInsensitive("__attach_version1.0_#00000001");
+ POIFSChunkParser.parse(with.getRoot());
ChunkGroup[] groups = POIFSChunkParser.parse(with.getRoot());
assertEquals(5, groups.length);
@@ -276,9 +277,10 @@ public final class TestPOIFSChunkParser {
assertEquals("pj1.txt", attachment.getAttachLongFileName().toString());
assertEquals(89, attachment.getAttachData().getValue().length);
- // Check raw details on one without
- assertFalse(without.getRoot().hasEntry("__attach_version1.0_#00000000"));
- assertFalse(without.getRoot().hasEntry("__attach_version1.0_#00000001"));
+
+ // Check raw details on one without
+ assertFalse(without.getRoot().hasEntryCaseInsensitive("__attach_version1.0_#00000000"));
+ assertFalse(without.getRoot().hasEntryCaseInsensitive("__attach_version1.0_#00000001"));
// One with, from the top
try (MAPIMessage msgWith = new MAPIMessage(with)) {
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFDocFixture.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFDocFixture.java
index ea2a93cc12..54052acc58 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFDocFixture.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/HWPFDocFixture.java
@@ -44,7 +44,7 @@ public final class HWPFDocFixture
POIDataSamples.getDocumentInstance().openResourceAsStream(_testFile));
DocumentEntry documentProps =
- (DocumentEntry) filesystem.getRoot().getEntry("WordDocument");
+ (DocumentEntry) filesystem.getRoot().getEntryCaseInsensitive("WordDocument");
_mainStream = new byte[documentProps.getSize()];
filesystem.createDocumentInputStream("WordDocument").read(_mainStream);
@@ -59,7 +59,7 @@ public final class HWPFDocFixture
// read in the table stream.
DocumentEntry tableProps =
- (DocumentEntry) filesystem.getRoot().getEntry(name);
+ (DocumentEntry) filesystem.getRoot().getEntryCaseInsensitive(name);
_tableStream = new byte[tableProps.getSize()];
filesystem.createDocumentInputStream(name).read(_tableStream);
diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/extractor/TestWordExtractor.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/extractor/TestWordExtractor.java
index 4ef67c44c8..a53fefd7fe 100644
--- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/extractor/TestWordExtractor.java
+++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/extractor/TestWordExtractor.java
@@ -142,15 +142,15 @@ public final class TestWordExtractor {
POIFSFileSystem fs = new POIFSFileSystem(is);
is.close();
- DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B7");
- DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B2");
+ DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntryCaseInsensitive("MBD0000A3B7");
+ DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntryCaseInsensitive("MBD0000A3B2");
// Should have WordDocument and 1Table
- assertNotNull(dirA.getEntry("1Table"));
- assertNotNull(dirA.getEntry("WordDocument"));
+ assertNotNull(dirA.getEntryCaseInsensitive("1Table"));
+ assertNotNull(dirA.getEntryCaseInsensitive("WordDocument"));
- assertNotNull(dirB.getEntry("1Table"));
- assertNotNull(dirB.getEntry("WordDocument"));
+ assertNotNull(dirB.getEntryCaseInsensitive("1Table"));
+ assertNotNull(dirB.getEntryCaseInsensitive("WordDocument"));
// Check each in turn
HWPFDocument docA = new HWPFDocument(dirA);
@@ -403,6 +403,18 @@ public final class TestWordExtractor {
}
@Test
+ public void testCaseInsensitiveOLENames() throws Exception {
+ //test files are from Ross Johnson on TIKA-4091
+ for (String n : new String[]{"normal", "lower", "upper"}) {
+ try (InputStream is = docTests.openResourceAsStream("47950_" + n + ".doc");
+ POIFSFileSystem fs = new POIFSFileSystem(is);
+ WordExtractor wExt = new WordExtractor(fs)) {
+ assertContains(wExt.getText(), "This is a sample Word document");
+ }
+ }
+ }
+
+ @Test
void testCapitalized() throws Exception {
try (WordExtractor wExt = openExtractor("capitalized.doc")) {
String text = wExt.getText().trim();