MediaType type = detector.detect(stream, metadata);
metadata.set(Metadata.CONTENT_TYPE, type.toString());
// TIKA-216: Zip bomb prevention
CountingInputStream count = new CountingInputStream(stream);
SecureContentHandler secure = new SecureContentHandler(handler, count);
// Parse the document
try {
super.parse(count, secure, metadata, context);
} catch (SAXException e) {
// Convert zip bomb exceptions to TikaExceptions
secure.throwIfCauseOf(e);
throw e;
}
}