Skip to main content

MAX_PREDICATE_NESTING_DEPTH

Constant MAX_PREDICATE_NESTING_DEPTH 

Source
pub const MAX_PREDICATE_NESTING_DEPTH: u32 = 8;
Expand description

Maximum predicate-nesting depth accepted by parse_xpath_with.

XPath eval is O(N^k) in document size N and predicate-nesting depth k. Realistic queries rarely exceed depth 3 (//section[chapter[ paragraph[contains(., 'x')]]]); legitimate generated XPath (e.g., SPARQL→XPath translation) sometimes reaches depth 4-5. Eight is a generous ceiling that lets every legitimate pattern through while rejecting the obviously-adversarial inputs the fuzzer finds (//*[//*[//*[//*[//*[//*[//*[.='x']]]]]]] at depth 7 burns the full 500k step budget in tens of milliseconds — caught here in microseconds at parse time).