You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2015/04/23 20:35:15 UTC
svn commit: r1675702 - in /poi/trunk/src:
java/org/apache/poi/poifs/property/PropertyTableBase.java
testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java
Author: nick
Date: Thu Apr 23 18:35:15 2015
New Revision: 1675702
URL: http://svn.apache.org/r1675702
Log:
#57851 - Skip null properties in PropertyTableBase, which is how PropertyFactory reports unsupported POIFS properties
Modified:
poi/trunk/src/java/org/apache/poi/poifs/property/PropertyTableBase.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java
Modified: poi/trunk/src/java/org/apache/poi/poifs/property/PropertyTableBase.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/property/PropertyTableBase.java?rev=1675702&r1=1675701&r2=1675702&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/property/PropertyTableBase.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/property/PropertyTableBase.java Thu Apr 23 18:35:15 2015
@@ -111,6 +111,11 @@ public abstract class PropertyTableBase
while (!children.empty())
{
Property property = children.pop();
+ if (property == null)
+ {
+ // unknown / unsupported / corrupted property, skip
+ continue;
+ }
root.addChild(property);
if (property.isDirectory())
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java?rev=1675702&r1=1675701&r2=1675702&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java Thu Apr 23 18:35:15 2015
@@ -44,15 +44,22 @@ public final class TestFileSystemBugs ex
}
openedFSs = null;
}
- protected DirectoryNode[] openSample(String name) throws Exception {
- POIFSFileSystem ofs = new POIFSFileSystem(
- _samples.openResourceAsStream(name));
+ protected DirectoryNode[] openSample(String name, boolean oldFails) throws Exception {
NPOIFSFileSystem nfs = new NPOIFSFileSystem(
_samples.openResourceAsStream(name));
-
if (openedFSs == null) openedFSs = new ArrayList<NPOIFSFileSystem>();
openedFSs.add(nfs);
+ POIFSFileSystem ofs = null;
+ try {
+ ofs = new POIFSFileSystem(
+ _samples.openResourceAsStream(name));
+ if (oldFails) fail("POIFSFileSystem should have failed but didn't");
+ } catch (Exception e) {
+ if (!oldFails) throw e;
+ }
+
+ if (ofs == null) return new DirectoryNode[] { nfs.getRoot() };
return new DirectoryNode[] { ofs.getRoot(), nfs.getRoot() };
}
@@ -62,7 +69,7 @@ public final class TestFileSystemBugs ex
*/
public void testNotesOLE2Files() throws Exception {
// Check the contents
- for (DirectoryNode root : openSample("Notes.ole2")) {
+ for (DirectoryNode root : openSample("Notes.ole2", false)) {
assertEquals(1, root.getEntryCount());
Entry entry = root.getEntries().next();
@@ -87,4 +94,17 @@ public final class TestFileSystemBugs ex
assertEquals("\u0001CompObj", entry.getName());
}
}
+
+ /**
+ * Ensure that a file with a corrupted property in the
+ * properties table can still be loaded, and the remaining
+ * properties used
+ * Note - only works for NPOIFSFileSystem, POIFSFileSystem
+ * can't cope with this level of corruption
+ */
+ public void testCorruptedProperties() throws Exception {
+ for (DirectoryNode root : openSample("unknown_properties.msg", true)) {
+ assertEquals(42, root.getEntryCount());
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org