mirror of https://github.com/apache/poi.git
#57851 - Skip null properties in PropertyTableBase, which is how PropertyFactory reports unsupported POIFS properties
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1675702 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4a33fe786c
commit
ac7b4bc3dd
|
@ -111,6 +111,11 @@ public abstract class PropertyTableBase implements BATManaged {
|
||||||
while (!children.empty())
|
while (!children.empty())
|
||||||
{
|
{
|
||||||
Property property = children.pop();
|
Property property = children.pop();
|
||||||
|
if (property == null)
|
||||||
|
{
|
||||||
|
// unknown / unsupported / corrupted property, skip
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
root.addChild(property);
|
root.addChild(property);
|
||||||
if (property.isDirectory())
|
if (property.isDirectory())
|
||||||
|
|
|
@ -44,15 +44,22 @@ public final class TestFileSystemBugs extends TestCase {
|
||||||
}
|
}
|
||||||
openedFSs = null;
|
openedFSs = null;
|
||||||
}
|
}
|
||||||
protected DirectoryNode[] openSample(String name) throws Exception {
|
protected DirectoryNode[] openSample(String name, boolean oldFails) throws Exception {
|
||||||
POIFSFileSystem ofs = new POIFSFileSystem(
|
|
||||||
_samples.openResourceAsStream(name));
|
|
||||||
NPOIFSFileSystem nfs = new NPOIFSFileSystem(
|
NPOIFSFileSystem nfs = new NPOIFSFileSystem(
|
||||||
_samples.openResourceAsStream(name));
|
_samples.openResourceAsStream(name));
|
||||||
|
|
||||||
if (openedFSs == null) openedFSs = new ArrayList<NPOIFSFileSystem>();
|
if (openedFSs == null) openedFSs = new ArrayList<NPOIFSFileSystem>();
|
||||||
openedFSs.add(nfs);
|
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() };
|
return new DirectoryNode[] { ofs.getRoot(), nfs.getRoot() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +69,7 @@ public final class TestFileSystemBugs extends TestCase {
|
||||||
*/
|
*/
|
||||||
public void testNotesOLE2Files() throws Exception {
|
public void testNotesOLE2Files() throws Exception {
|
||||||
// Check the contents
|
// Check the contents
|
||||||
for (DirectoryNode root : openSample("Notes.ole2")) {
|
for (DirectoryNode root : openSample("Notes.ole2", false)) {
|
||||||
assertEquals(1, root.getEntryCount());
|
assertEquals(1, root.getEntryCount());
|
||||||
|
|
||||||
Entry entry = root.getEntries().next();
|
Entry entry = root.getEntries().next();
|
||||||
|
@ -87,4 +94,17 @@ public final class TestFileSystemBugs extends TestCase {
|
||||||
assertEquals("\u0001CompObj", entry.getName());
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue