[ 
https://issues.apache.org/jira/browse/TIKA-4857?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18109524#comment-18109524
 ] 

ASF GitHub Bot commented on TIKA-4857:
--------------------------------------

dschmidt opened a new pull request, #3098:
URL: https://github.com/apache/tika/pull/3098

   `ParseRecord.depth` is incremented for every composite parser a parse passes 
through. With `AutoDetectParser` wrapping `DefaultParser` that is two per 
document level, and the depth check compared that counter with `maxDepth + 1`, 
so `maxDepth=2` parsed depth 1 only, `maxDepth=3` reached depth 2, and so on. 
`maxDepth=0` and `1` happened to work, which is what the existing tests cover.
   
   `ParseRecord` now has an embedding depth that 
`ParsingEmbeddedDocumentExtractor` and `UnpackExtractor` raise around the 
child's parse, and the limit is checked against that: with `maxDepth=N`, 
documents at depth N are parsed and their children are not, as the 
`EmbeddedLimits` javadoc describes. The composite counter stays as it is for 
its other uses (top-level detection, handler decoration).
   
   The new test nests a parser five levels deep behind two composite layers and 
fails on main for maxDepth 2, 3 and 5.
   
   https://issues.apache.org/jira/browse/TIKA-4857
   




> embedded-limits.maxDepth counts parser layers, not embedding levels
> -------------------------------------------------------------------
>
>                 Key: TIKA-4857
>                 URL: https://issues.apache.org/jira/browse/TIKA-4857
>             Project: Tika
>          Issue Type: Bug
>            Reporter: Dominik Schmidt
>            Priority: Major
>
> The javadoc of EmbeddedLimits says maxDepth is the maximum nesting depth of 
> embedded documents that are still parsed (maxDepth=1: depth 1 parsed, depth 2 
> not). In practice maxDepth=2 parses depth 1 only; depth 2 needs maxDepth=3.
> Reproduced with RecursiveParserWrapper on a DOCX whose EMF thumbnail is 
> rendered (the rendering is a depth-2 embedded document):
> - maxDepth 1: depth 1 only, tk:exception:embedded-depth-limit-reached set
> - maxDepth 2: depth 1 only, limit reached set
> - maxDepth 3: depth 1 and 2
> - maxDepth -1: everything
> ParseRecord.depth is incremented in CompositeParser.parse for every composite 
> layer a parse passes through; with AutoDetectParser wrapping DefaultParser 
> that is two increments per document level, and 
> ParsingEmbeddedDocumentExtractor compares that counter with maxDepth + 1. The 
> limit should be checked against the embedding depth (tk:embedded-depth of the 
> child), independent of how parsers are composed. The same off-by-one applies 
> to /unpack with embedded-limits in tika-server.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to