oa_gateway_agra

Function nesting_exceeds

Source
pub(crate) fn nesting_exceeds(text: &str, limit: usize) -> bool
Expand description

Whether xml nests elements deeper than limit, checked on the text rather than a parsed tree.

Deliberately an over-estimate: rejecting an odd document costs a message, while under-counting costs the process, so anything ambiguous counts as nesting. A < inside a comment, a processing instruction, or a DOCTYPE is skipped, since none of them open an element. Quoting inside a start tag is tracked for the opposite reason: > and /> are legal in an attribute value, and treating one as the end of a tag is how a deep document would pass for a shallow one.