mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 16:24:38 +00:00
Document and test inherited namespace declaration budget
This commit is contained in:
1 parent
1a0d5d6078
commit
c50eb61065
2 files changed
+19
No files matched your search
@@ -7,3 +7,5 @@ Preserves source byte ranges, coalesced text, namespace shadowing and document-l
|
||||
Original source by Dylan M. Taylor (eead4541, 7d44e654), MIT OR Apache-2.0.
|
||||
|
||||
Compatibility delta versus the original app XML pin e2dc681a3: current strict craft-xml rejects duplicate raw or expanded attribute names. This deliberately preserves shared security hardening; valid-document DOM behavior is unchanged, but malformed acceptance and errors are not promised byte-identical. Regression tests cover both duplicate forms.
|
||||
|
||||
The updated strict reader also bounds aggregate active namespace declarations to 1024 across ancestor elements, not just attributes per tag. The old app path could accept more inherited declarations. The exact boundary and one-over case are tested; this intentional tighter resource admission is retained.
|
||||
@@ -411,6 +411,23 @@ mod tests {
|
||||
assert_eq!(root.range(), 0..text.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inherited_namespace_declarations_have_an_aggregate_budget() {
|
||||
use std::fmt::Write;
|
||||
let mut xml = String::from("<r");
|
||||
for i in 0..512 {
|
||||
write!(xml, " xmlns:p{i}='u{i}'").unwrap();
|
||||
}
|
||||
xml.push_str("><child");
|
||||
for i in 512..1024 {
|
||||
write!(xml, " xmlns:p{i}='u{i}'").unwrap();
|
||||
}
|
||||
let accepted = format!("{xml}/></r>");
|
||||
assert!(Document::parse(&accepted).is_ok());
|
||||
let rejected = format!("{xml} xmlns:extra='extra'/></r>");
|
||||
assert!(Document::parse(&rejected).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_dtd_and_resource_limits_are_preserved() {
|
||||
// Current shared XML rejects duplicate attributes, unlike the older app pin.
|
||||
|
||||
Reference in new issue
Block a user