temporary workaround -- check for zero length byte array in
rtf body to avoid buffer underflow from POI, via Pascal Essiembre.
@@ -74,6 +74,7 @@ import org.apache.tika.parser.txt.CharsetMatch;
import org.apache.tika.sax.BodyContentHandler;
import org.apache.tika.sax.EmbeddedContentHandler;
import org.apache.tika.sax.XHTMLContentHandler;
+import org.bouncycastle.cms.Recipient;
import org.xml.sax.SAXException;
/**
@@ -321,6 +322,10 @@ public class OutlookExtractor extends AbstractPOIFSExtractor {
}
if (rtfChunk != null && (extractAllAlternatives || !doneBody)) {
ByteChunk chunk = (ByteChunk) rtfChunk;
+ //avoid buffer underflow TIKA-2530
+ //TODO -- would be good to find an example triggering file and
+ //figure out if this is a bug in POI or a genuine 0 length chunk
+ if (chunk.getValue() != null && chunk.getValue().length > 0) {
MAPIRtfAttribute rtf = new MAPIRtfAttribute(
MAPIProperty.RTF_COMPRESSED, Types.BINARY.getId(), chunk.getValue()
);
@@ -335,6 +340,7 @@ public class OutlookExtractor extends AbstractPOIFSExtractor {
new Metadata(), parseContext);
doneBody = true;
}
+ }
if (textChunk != null && (extractAllAlternatives || !doneBody)) {
xhtml.element("p", ((StringChunk) textChunk).getValue());
}
