oa_gateway_uci::xml

Function nesting_exceeds

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

Whether element nesting in text could exceed limit, without building a tree.

Deliberately an over-estimate. Rejecting an odd document costs a message; under-counting costs the process, so anything ambiguous counts as nesting. Comments, processing instructions, DOCTYPEs, and CDATA are skipped, since a < inside them is text rather than 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.