fixed bug 42486: Failure parsing a seemingly valid PPT. Some of the assertions in ExHyperlink were too strong. Write to log instead of throwing exception
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@541632 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3bcdf011d1
commit
09b709f426
@ -20,6 +20,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* This class represents the data of a link in the document.
|
||||
@ -93,35 +94,23 @@ public class ExHyperlink extends RecordContainer {
|
||||
* methods.
|
||||
*/
|
||||
private void findInterestingChildren() {
|
||||
// We need to have 2 children, ideally 3, and sometimes have more
|
||||
if(_children.length < 2) {
|
||||
throw new IllegalStateException("We need at least two child records, but we only had " + _children.length);
|
||||
}
|
||||
|
||||
// First child should be the ExHyperlinkAtom
|
||||
if(_children[0] instanceof ExHyperlinkAtom) {
|
||||
linkAtom = (ExHyperlinkAtom)_children[0];
|
||||
} else {
|
||||
throw new IllegalStateException("First child record wasn't a ExHyperlinkAtom, was of type " + _children[0].getRecordType());
|
||||
logger.log(POILogger.ERROR, "First child record wasn't a ExHyperlinkAtom, was of type " + _children[0].getRecordType());
|
||||
}
|
||||
|
||||
// Second child should be the first link details
|
||||
if(_children[1] instanceof CString) {
|
||||
linkDetailsA = (CString)_children[1];
|
||||
} else {
|
||||
throw new IllegalStateException("Second child record wasn't a CString, was of type " + _children[1].getRecordType());
|
||||
}
|
||||
for (int i = 1; i < _children.length; i++) {
|
||||
if (_children[i] instanceof CString){
|
||||
if ( linkDetailsA == null) linkDetailsA = (CString)_children[i];
|
||||
else linkDetailsB = (CString)_children[i];
|
||||
} else {
|
||||
logger.log(POILogger.ERROR, "Record after ExHyperlinkAtom wasn't a CString, was of type " + _children[1].getRecordType());
|
||||
}
|
||||
|
||||
// Third child, if it exists, should be the second link details
|
||||
if(_children.length >= 3) {
|
||||
if(_children[2] instanceof CString) {
|
||||
linkDetailsB = (CString)_children[2];
|
||||
} else {
|
||||
throw new IllegalStateException("Third child record wasn't a CString, was of type " + _children[2].getRecordType());
|
||||
}
|
||||
} else {
|
||||
// Should be fine to not have one
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
BIN
src/scratchpad/testcases/org/apache/poi/hslf/data/42486.ppt
Normal file
BIN
src/scratchpad/testcases/org/apache/poi/hslf/data/42486.ppt
Normal file
Binary file not shown.
@ -184,4 +184,21 @@ public class TestBugs extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug 42486: Failure parsing a seemingly valid PPT
|
||||
*/
|
||||
public void test42486 () throws Exception {
|
||||
FileInputStream is = new FileInputStream(new File(cwd, "42486.ppt"));
|
||||
HSLFSlideShow hslf = new HSLFSlideShow(is);
|
||||
is.close();
|
||||
|
||||
SlideShow ppt = new SlideShow(hslf);
|
||||
Slide[] slide = ppt.getSlides();
|
||||
for (int i = 0; i < slide.length; i++) {
|
||||
Shape[] shape = slide[i].getShapes();
|
||||
}
|
||||
assertTrue("No Exceptions while reading file", true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user