diff --git a/crates/domistream/tests/http.rs b/crates/domistream/tests/http.rs index d7e922b..477981f 100644 --- a/crates/domistream/tests/http.rs +++ b/crates/domistream/tests/http.rs @@ -166,13 +166,15 @@ fn xml_depth_bomb_does_not_recurse() { s.push_str(&"".repeat(300_000)); assert!(s.len() < MAX_XML_BYTES); assert_cap!(xml::parse(s.as_bytes()), MAX_XML_DEPTH); - // Same with the closing tags present. - s.push_str(&"".repeat(300_000)); - s.push_str(""); - assert!(s.len() < MAX_XML_BYTES * 2); - if s.len() <= MAX_XML_BYTES { - assert_cap!(xml::parse(s.as_bytes()), MAX_XML_DEPTH); - } + // A closed, well-formed bomb that fits under the size cap (100 000 opens + 100 000 closes, about 0.7 MB): still + // refused at depth 9, never parsed by recursion. (The earlier 300 000-pair version was 2.1 MB, over the size + // cap, so its depth check never ran: ruled wrong 2026-11-26.) + let mut closed = String::from(""); + closed.push_str(&"".repeat(100_000)); + closed.push_str(&"".repeat(100_000)); + closed.push_str(""); + assert!(closed.len() <= MAX_XML_BYTES, "{} bytes must fit the size cap", closed.len()); + assert_cap!(xml::parse(closed.as_bytes()), MAX_XML_DEPTH); } #[test]