pass through TikaConfig via ParseContext in AutoDetectParser
@@ -36,6 +36,7 @@ public class AutoDetectParser extends CompositeParser {
/** Serial version UID */
private static final long serialVersionUID = 6110455808615143122L;
+ private final TikaConfig config;
/**
* The type detector used by this parser to auto-detect the type
@@ -71,11 +72,13 @@ public class AutoDetectParser extends CompositeParser {
public AutoDetectParser(Detector detector, Parser...parsers) {
super(MediaTypeRegistry.getDefaultRegistry(), parsers);
setDetector(detector);
+ config = TikaConfig.getDefaultConfig();
}
public AutoDetectParser(TikaConfig config) {
super(config.getMediaTypeRegistry(), config.getParser());
setDetector(config.getDetector());
+ this.config = config;
}
/**
@@ -115,6 +118,13 @@ public class AutoDetectParser extends CompositeParser {
// TIKA-216: Zip bomb prevention
SecureContentHandler sch =
handler != null ? new SecureContentHandler(handler, tis) : null;
+
+ //pass the config to the parsers if
+ //the caller hasn't specified one.
+ if (context.get(TikaConfig.class) == null) {
+ context.set(TikaConfig.class, config);
+ }
+
try {
// Parse the document
super.parse(tis, sch, metadata, context);
