Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

358
vendor/roxmltree/tests/api.rs vendored Normal file
View File

@@ -0,0 +1,358 @@
#![allow(clippy::bool_assert_comparison)]
use roxmltree::*;
#[test]
fn error_size() {
assert!(::std::mem::size_of::<Error>() <= 64);
}
#[test]
fn root_element_01() {
let data = "\
<!-- comment -->
<e/>
";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(node.tag_name().name(), "e");
}
#[test]
fn get_text_01() {
let data = "\
<root>
Text1
<item>
Text2
</item>
Text3
</root>
";
let doc = Document::parse(data).unwrap();
let root = doc.root_element();
assert_eq!(root.text(), Some("\n Text1\n "));
assert_eq!(root.tail(), None);
let item = root.children().nth(1).unwrap();
assert_eq!(item.text(), Some("\n Text2\n "));
assert_eq!(item.tail(), Some("\n Text3\n"));
}
#[test]
fn get_text_02() {
let data = "<root>&apos;</root>";
let doc = Document::parse(data).unwrap();
let root = doc.root_element();
assert_eq!(root.text(), Some("'"));
}
#[test]
fn api_01() {
let data = "\
<e a:attr='a_ns' b:attr='b_ns' attr='no_ns' xmlns:b='http://www.ietf.org' \
xmlns:a='http://www.w3.org' xmlns='http://www.uvic.ca'/>
";
let doc = Document::parse(data).unwrap();
let p = doc.root_element();
assert_eq!(p.attribute("attr"), Some("no_ns"));
assert_eq!(p.has_attribute("attr"), true);
assert_eq!(p.attribute(("http://www.w3.org", "attr")), Some("a_ns"));
assert_eq!(p.has_attribute(("http://www.w3.org", "attr")), true);
assert_eq!(p.attribute("attr2"), None);
assert_eq!(p.has_attribute("attr2"), false);
assert_eq!(p.attribute(("http://www.w2.org", "attr")), None);
assert_eq!(p.has_attribute(("http://www.w2.org", "attr")), false);
assert_eq!(p.attribute("b"), None);
assert_eq!(p.has_attribute("b"), false);
assert_eq!(p.attribute("xmlns"), None);
assert_eq!(p.has_attribute("xmlns"), false);
}
#[test]
fn get_pi() {
let data = "\
<?target value?>
<root/>
";
let doc = Document::parse(data).unwrap();
let node = doc.root().first_child().unwrap();
assert_eq!(
node.pi(),
Some(PI {
target: "target",
value: Some("value")
})
);
}
#[test]
fn lookup_prefix_01() {
let data = "<e xmlns:n1='http://www.w3.org' n1:a='b1'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(node.lookup_prefix("http://www.w3.org"), Some("n1"));
assert_eq!(node.lookup_prefix("http://www.w4.org"), None);
}
#[test]
fn lookup_prefix_02() {
let data = "<e xml:space='preserve'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(node.lookup_prefix(NS_XML_URI), Some("xml"));
}
#[test]
fn lookup_namespace_uri() {
let data = "<e xmlns:n1='http://www.w3.org' xmlns='http://www.w4.org'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(
node.lookup_namespace_uri(Some("n1")),
Some("http://www.w3.org")
);
assert_eq!(node.lookup_namespace_uri(None), Some("http://www.w4.org"));
assert_eq!(node.lookup_namespace_uri(Some("n2")), None);
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_01() {
let data = "\
<e a='b'>
<!-- comment -->
<p>Text</p>
</e>
";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(
doc.text_pos_at(doc.root().range().start),
TextPos::new(1, 1)
);
assert_eq!(doc.text_pos_at(doc.root().range().end), TextPos::new(5, 1));
assert_eq!(doc.text_pos_at(node.range().start), TextPos::new(1, 1));
assert_eq!(doc.text_pos_at(node.range().end), TextPos::new(4, 5));
if let Some(attr) = node.attribute_node("a") {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 4));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 9));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 4));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 5));
assert_eq!(doc.text_pos_at(attr.range_value().start), TextPos::new(1, 7));
assert_eq!(doc.text_pos_at(attr.range_value().end), TextPos::new(1, 8));
}
// first child is a text/whitespace, not a comment
let comm = node.first_child().unwrap().next_sibling().unwrap();
assert_eq!(doc.text_pos_at(comm.range().start), TextPos::new(2, 5));
let p = comm.next_sibling().unwrap().next_sibling().unwrap();
assert_eq!(doc.text_pos_at(p.range().start), TextPos::new(3, 5));
let text = p.first_child().unwrap();
assert_eq!(doc.text_pos_at(text.range().start), TextPos::new(3, 8));
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_02() {
let data = "<n1:e xmlns:n1='http://www.w3.org' n1:a='b'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(doc.text_pos_at(node.range().start), TextPos::new(1, 1));
if let Some(attr) = node.attribute_node(("http://www.w3.org", "a")) {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 44));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 40));
assert_eq!(doc.text_pos_at(attr.range_value().start), TextPos::new(1, 42));
assert_eq!(doc.text_pos_at(attr.range_value().end), TextPos::new(1, 43));
}
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_03() {
let data = "\
<!-- comment -->
<e/>
";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(doc.text_pos_at(node.range().start), TextPos::new(2, 1));
assert_eq!(doc.text_pos_at(node.range().end), TextPos::new(2, 5));
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_04() {
let data = "<n1:e xmlns:n1='http://www.w3.org' n1:a=''/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
if let Some(attr) = node.attribute_node("a") {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 43));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 40));
assert_eq!(doc.text_pos_at(attr.range_value().start), TextPos::new(1, 42));
assert_eq!(doc.text_pos_at(attr.range_value().end), TextPos::new(1, 42));
}
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_05() {
let data = "<n1:e xmlns:n1='http://www.w3.org' n1:a = 'b'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
if let Some(attr) = node.attribute_node("a") {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 48));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 40));
assert_eq!(doc.text_pos_at(attr.range_value().start), TextPos::new(1, 47));
assert_eq!(doc.text_pos_at(attr.range_value().end), TextPos::new(1, 48));
}
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_06() {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
let data = "<e a = 'b'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
if let Some(attr) = node.attribute_node("a") {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 4));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 269));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 4));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 5));
attr.range_value(); // unreliable since >254 spaces around equal sign, but still shouldn't panic
}
}
#[test]
fn next_sibling_element_01() {
let data = "<root><a/><b/><c/></root>";
let doc = roxmltree::Document::parse(data).unwrap();
let root = doc.root_element();
let a = root.first_element_child().unwrap();
let b = a.next_sibling_element().unwrap();
let c = b.next_sibling_element().unwrap();
assert!(c.next_sibling_element().is_none());
assert_eq!(root.tag_name().name(), "root");
assert_eq!(a.tag_name().name(), "a");
assert_eq!(b.tag_name().name(), "b");
assert_eq!(c.tag_name().name(), "c");
}
#[test]
fn next_prev_element_01() {
let data = "<root><a/><b/><c/></root>";
let doc = roxmltree::Document::parse(data).unwrap();
let root = doc.root_element();
let c = root.last_element_child().unwrap();
let b = c.prev_sibling_element().unwrap();
let a = b.prev_sibling_element().unwrap();
assert!(a.prev_sibling_element().is_none());
assert_eq!(root.tag_name().name(), "root");
assert_eq!(a.tag_name().name(), "a");
assert_eq!(b.tag_name().name(), "b");
assert_eq!(c.tag_name().name(), "c");
}
#[test]
fn nodes_document_order() {
let data = "<root><a/><b/><c/></root>";
let doc = roxmltree::Document::parse(data).unwrap();
let root = doc.root_element();
let a = root.first_element_child().unwrap();
let b = a.next_sibling_element().unwrap();
let c = b.next_sibling_element().unwrap();
let mut elems = vec![&b, &c, &a];
elems.sort();
assert!(elems[0] == &a);
assert!(elems[1] == &b);
assert!(elems[2] == &c);
}
#[test]
fn lifetimes() {
fn f<'a, 'd, F, R>(doc: &'a roxmltree::Document<'d>, fun: F) -> R
where
F: Fn(&'a roxmltree::Document<'d>) -> R,
{
fun(doc)
}
let doc = roxmltree::Document::parse("<e xmlns='http://www.w3.org'/>").unwrap();
let _ = f(&doc, |d| d.root());
let _ = f(&doc, |d| d.root().document());
let _ = f(&doc, |d| d.root().tag_name());
let _ = f(&doc, |d| d.root().tag_name().namespace());
let _ = f(&doc, |d| d.root().tag_name().name());
let _ = f(&doc, |d| d.root().default_namespace());
let _ = f(&doc, |d| d.root().lookup_prefix(""));
let _ = f(&doc, |d| d.root().lookup_namespace_uri(None));
let _ = f(&doc, |d| d.root().attribute("a"));
let _ = f(&doc, |d| d.root().attribute_node("a"));
let _ = f(&doc, |d| d.root().attributes());
let _ = f(&doc, |d| d.root().namespaces());
let _ = f(&doc, |d| d.root().text());
let _ = f(&doc, |d| d.root().tail());
let _ = f(&doc, |d| d.root().pi());
}
#[test]
fn tag_name_lifetime() {
fn get_tag_name<'a, 'input>(node: &'a Node<'a, 'input>) -> &'input str {
node.tag_name().name()
}
let data = "<e xmlns='http://www.w3.org' />";
let doc = roxmltree::Document::parse(data).unwrap();
let root = doc.root_element();
assert_eq!(get_tag_name(&root), "e");
}

292
vendor/roxmltree/tests/ast.rs vendored Normal file
View File

@@ -0,0 +1,292 @@
use roxmltree::*;
use std::fmt;
use std::fmt::Write;
use std::fs;
use std::io::Read;
use std::path;
#[derive(Clone, Copy, PartialEq)]
struct TStr<'a>(pub &'a str);
impl<'a> fmt::Debug for TStr<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
trait HasExtension {
fn has_extension(&self, ext: &str) -> bool;
}
impl HasExtension for path::Path {
fn has_extension(&self, ext: &str) -> bool {
if let Some(e) = self.extension() {
e == ext
} else {
false
}
}
}
fn actual_test(path: &str) {
let path = path::Path::new(path);
let expected = load_file(&path.with_extension("yaml"));
let opt = ParsingOptions {
allow_dtd: true,
..roxmltree::ParsingOptions::default()
};
let input_xml = load_file(path);
let doc = match Document::parse_with_options(&input_xml, opt) {
Ok(v) => v,
Err(e) => {
assert_eq!(TStr(&format!("error: \"{}\"", e)), TStr(expected.trim()));
return;
}
};
assert_eq!(TStr(&to_yaml(&doc)), TStr(&expected));
}
fn load_file(path: &path::Path) -> String {
let mut file = fs::File::open(path).unwrap();
let mut text = String::new();
file.read_to_string(&mut text).unwrap();
text
}
fn to_yaml(doc: &Document) -> String {
let mut s = String::new();
_to_yaml(doc, &mut s).unwrap();
s
}
fn _to_yaml(doc: &Document, s: &mut String) -> Result<(), fmt::Error> {
if !doc.root().has_children() {
return write!(s, "Document:");
}
macro_rules! writeln_indented {
($depth:expr, $f:expr, $fmt:expr) => {
for _ in 0..$depth { write!($f, " ")?; }
writeln!($f, $fmt)?;
};
($depth:expr, $f:expr, $fmt:expr, $($arg:tt)*) => {
for _ in 0..$depth { write!($f, " ")?; }
writeln!($f, $fmt, $($arg)*)?;
};
}
fn print_children(parent: Node, depth: usize, s: &mut String) -> Result<(), fmt::Error> {
for child in parent.children() {
match child.node_type() {
NodeType::Element => {
writeln_indented!(depth, s, "- Element:");
match child.tag_name().namespace() {
Some(ns) => {
if ns.is_empty() {
writeln_indented!(
depth + 2,
s,
"tag_name: {}",
child.tag_name().name()
);
} else {
writeln_indented!(
depth + 2,
s,
"tag_name: {}@{}",
child.tag_name().name(),
ns
);
}
}
None => {
writeln_indented!(
depth + 2,
s,
"tag_name: {}",
child.tag_name().name()
);
}
}
let attributes = child.attributes();
if attributes.len() != 0 {
let mut attrs = Vec::new();
for attr in attributes {
match attr.namespace() {
Some(ns) => {
attrs.push((format!("{}@{}", attr.name(), ns), attr.value()));
}
None => {
attrs.push((attr.name().to_string(), attr.value()));
}
}
}
attrs.sort_by(|a, b| a.0.cmp(&b.0));
writeln_indented!(depth + 2, s, "attributes:");
for (name, value) in attrs {
writeln_indented!(depth + 3, s, "{}: {:?}", name, value);
}
}
let namespaces = child.namespaces();
if namespaces.len() != 0 {
let mut ns_list = Vec::new();
for ns in namespaces {
let name = ns.name().unwrap_or("None");
let uri = if ns.uri().is_empty() {
"\"\""
} else {
ns.uri()
};
ns_list.push((name, uri));
}
ns_list.sort_by(|a, b| a.0.cmp(b.0));
writeln_indented!(depth + 2, s, "namespaces:");
for (name, uri) in ns_list {
writeln_indented!(depth + 3, s, "{}: {}", name, uri);
}
}
if child.has_children() {
writeln_indented!(depth + 2, s, "children:");
print_children(child, depth + 3, s)?;
}
}
NodeType::Text => {
writeln_indented!(depth, s, "- Text: {:?}", child.text().unwrap());
}
NodeType::Comment => {
writeln_indented!(depth, s, "- Comment: {:?}", child.text().unwrap());
}
NodeType::PI => {
if child.parent().unwrap().is_root() {
continue;
}
writeln_indented!(depth, s, "- PI:");
let pi = child.pi().unwrap();
writeln_indented!(depth + 2, s, "target: {:?}", pi.target);
if let Some(value) = pi.value {
writeln_indented!(depth + 2, s, "value: {:?}", value);
}
}
NodeType::Root => {}
}
}
Ok(())
}
writeln!(s, "Document:")?;
print_children(doc.root(), 1, s)?;
Ok(())
}
macro_rules! test {
($name:ident) => {
#[test]
fn $name() {
actual_test(&format!("tests/files/{}.xml", stringify!($name)))
}
};
}
test!(attrs_001);
test!(attrs_002);
test!(attrs_003);
test!(attrs_004);
test!(attrs_005);
test!(attrs_006);
test!(attrs_err_001);
test!(attrs_err_002);
test!(cdata_001);
test!(cdata_002);
test!(cdata_003);
test!(cdata_004);
test!(cdata_005);
test!(cdata_006);
test!(cdata_007);
test!(comments_001);
test!(elems_err_001);
test!(elems_err_002);
test!(entity_001);
test!(entity_002);
test!(entity_003);
test!(entity_004);
test!(entity_005);
test!(entity_006);
test!(entity_007);
test!(entity_008);
test!(entity_009);
test!(entity_010);
test!(entity_011);
test!(entity_012);
test!(entity_013);
test!(entity_014);
test!(entity_err_001);
test!(entity_err_002);
test!(entity_err_003);
test!(entity_err_004);
test!(entity_err_005);
test!(entity_err_006);
test!(entity_err_007);
test!(entity_err_008);
test!(entity_err_009);
test!(ns_001);
test!(ns_002);
test!(ns_003);
test!(ns_004);
test!(ns_005);
test!(ns_006);
test!(ns_007);
test!(ns_008);
test!(ns_009);
test!(ns_010);
test!(ns_011);
test!(ns_012);
test!(ns_013);
test!(ns_014);
test!(ns_015);
test!(ns_016);
test!(ns_017);
test!(ns_err_001);
test!(ns_err_002);
test!(ns_err_003);
test!(ns_err_004);
test!(ns_err_005);
test!(ns_err_006);
test!(ns_err_007);
test!(ns_err_008);
test!(ns_err_009);
test!(ns_err_010);
test!(ns_err_011);
test!(ns_err_012);
test!(ns_err_013);
test!(text_001);
test!(text_002);
test!(text_003);
test!(text_004);
test!(text_005);
test!(text_006);
test!(text_007);
test!(text_008);
test!(text_009);
test!(text_010);
test!(text_011);
test!(text_012);
test!(tree_001);
test!(tree_002);
// test!(tree_003); // unsupported
test!(tree_err_001);
test!(tree_err_002);
test!(tree_err_003);

205
vendor/roxmltree/tests/dom-api.rs vendored Normal file
View File

@@ -0,0 +1,205 @@
use roxmltree::*;
// Document.getElementsByTagName()
#[test]
fn get_elements_by_tag_name() {
let data = "\
<!-- comment -->
<svg>
<rect/>
<text>Text</text>
<g>
<!-- comment -->
<rect/>
</g>
</svg>
";
let doc = Document::parse(data).unwrap();
let nodes: Vec<Node> = doc
.descendants()
.filter(|n| n.has_tag_name("rect"))
.collect();
assert_eq!(nodes.len(), 2);
}
// Document.getElementsByTagNameNS()
#[test]
fn get_elements_by_tag_name_ns() {
let data = "\
<!-- comment -->
<svg xmlns:q='http://www.w3.org/'>
<rect/>
<text>Text</text>
<g>
<!-- comment -->
<q:rect/>
</g>
</svg>
";
let doc = Document::parse(data).unwrap();
let nodes: Vec<Node> = doc
.descendants()
.filter(|n| n.has_tag_name(("http://www.w3.org/", "rect")))
.collect();
assert_eq!(nodes.len(), 1);
}
// ParentNode.childElementCount
#[test]
fn child_element_count() {
let data = "\
<svg>
<rect/>
<!-- comment -->
<rect/>
<!-- comment -->
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let svg_elem = doc.root_element();
let count = svg_elem.children().filter(|n| n.is_element()).count();
assert_eq!(count, 3);
}
// ParentNode.children
#[test]
fn children() {
let data = "\
<svg>
<rect/>
<!-- comment -->
<rect/>
<!-- comment -->
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let svg_elem = doc.root_element();
let count = svg_elem.children().filter(|n| n.is_element()).count();
assert_eq!(count, 3);
}
// ParentNode.firstElementChild
#[test]
fn first_element_child() {
let data = "\
<svg>
<!-- comment -->
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let svg_elem = doc.root_element();
let elem = svg_elem.first_element_child().unwrap();
assert!(elem.has_tag_name("rect"));
// or
let elem = svg_elem.children().find(|n| n.is_element()).unwrap();
assert!(elem.has_tag_name("rect"));
}
// ParentNode.lastElementChild
#[test]
fn last_element_child() {
let data = "\
<svg>
<!-- comment -->
<rect/>
<!-- comment -->
</svg>
";
let doc = Document::parse(data).unwrap();
let svg_elem = doc.root_element();
let elem = svg_elem.last_element_child().unwrap();
assert!(elem.has_tag_name("rect"));
// or
let elem = svg_elem
.children()
.filter(|n| n.is_element())
.last()
.unwrap();
assert!(elem.has_tag_name("rect"));
}
// Document.getElementById
#[test]
fn get_element_by_id() {
let data = "\
<svg id='svg1'>
<circle id='circle1'/>
<g>
<rect id='rect1'/>
</g>
</svg>
";
let doc = Document::parse(data).unwrap();
let elem = doc
.descendants()
.find(|n| n.attribute("id") == Some("rect1"))
.unwrap();
assert!(elem.has_tag_name("rect"));
}
// Node.ownerDocument
#[test]
fn owner_document() {
let doc = Document::parse("<svg/>").unwrap();
let _elem = doc.root_element();
}
// Node.parentElement
#[test]
fn parent_element() {
let data = "\
<svg>
<!-- comment -->
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let rect = doc.descendants().find(|n| n.has_tag_name("rect")).unwrap();
assert!(rect.parent_element().unwrap().has_tag_name("svg"));
// or
assert!(rect
.ancestors()
.skip(1)
.find(|n| n.is_element())
.unwrap()
.has_tag_name("svg"));
}
// Node.contains
#[test]
fn contains() {
let data = "\
<svg>
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let svg = doc.root_element();
let rect = svg.first_child().unwrap();
assert!(svg.descendants().any(|n| n == rect));
}

91
vendor/roxmltree/tests/files/README.md vendored Normal file
View File

@@ -0,0 +1,91 @@
### Tests
- attrs_001 - simple attribute
- attrs_002 - attribute value with new lines
- attrs_003 - attribute value with escaped text
- attrs_004 - attribute value with escaped text
- attrs_005 - attribute value with \r\n
- attrs_006 - escaped `<`
- attrs_err_001 - duplicated attributes
- attrs_err_002 - duplicated attributes via namespaces
- cdata_001 - simple case
- cdata_002 - simple case
- cdata_003 - empty
- cdata_004 - simple case
- cdata_005 - mixed text and cdata
- cdata_006 - simple case
- cdata_007 - with \r
- comments_001 - comment before and after the root element
- elems_err_001 - invalid tree structure
- elems_err_002 - invalid tree structure with namespace
- entity_001 - entity reference to an element
- entity_002 - entity reference to an attribute value
- entity_003 - many entity references to an attribute value
- entity_004 - entity reference to a text
- entity_005 - unused entity reference
- entity_006 - entity reference to an escaped text
- entity_007 - indirect entity reference to an attribute value
- entity_008 - entity reference to an element
- entity_009 - entity reference to a mixed content
- entity_010 - entity reference to an element with an entity reference
- entity_011 - character and entity references in attributes
- entity_012 - mixed entity references in text
- entity_013 - many entity references in text
- entity_014 - many entity references in attribute
- entity_err_001 - unknown entity reference
- entity_err_002 - recursive entity references
- entity_err_003 - reference to a close tag
- entity_err_004 - reference to a close tag
- entity_err_005 - billion laughs
- entity_err_006 - billion laughs
- entity_err_007 - malformed entity inside an attribute
- entity_err_008 - malformed entity inside a character data/text
- entity_err_009 - escaped `<` inside an attribute inside an entity is an error
- ns_001 - attributes with different namespaces
- ns_002 - attribute is not affected by the default namespace
- ns_003 - attributes with different namespaces
- ns_004 - `href` with a custom prefix
- ns_005 - `xml` namespace resolving
- ns_006 - `xml` namespace overriding
- ns_007 - many namespaces
- ns_008 - namespace propagation
- ns_009 - namespace overwriting
- ns_010 - indirect namespace propagation
- ns_011 - empty URI
- ns_012 - namespace propagation
- ns_013 - namespace from entity
- ns_014 - no namespaces
- ns_015 - duplicated namespaces with different prefixes and a child element without prefix
- ns_016 - an empty element with namespace on parent
- ns_017 - duplicated namespaces with different prefixes and a child element with prefix
- ns_err_001 - invalid `xml` URI
- ns_err_002 - reserved URI
- ns_err_003 - reserved URI
- ns_err_004 - duplicated namespaces
- ns_err_005 - escaped namespace
- ns_err_006 - escaped namespace
- ns_err_007 - reserved URI
- ns_err_008 - reserved URI
- ns_err_009 - `xmlns` cannot be used as an element prefix
- ns_err_010 - an element with an unknown namespace
- ns_err_011 - an attribute with an unknown namespace
- ns_err_012 - closing tag with missing namespace prefix
- ns_err_013 - closing tag with missing namespace prefix and default namespace
- text_001 - single space text
- text_002 - single escaped space text
- text_003 - escaped text
- text_004 - '>' text
- text_005 - '\n\r\r\n' text
- text_006 - '\r\r\r' text
- text_007 - '\r\n\r\n' text
- text_008 - only whitespaces
- text_009 - escaped text
- text_010 - text around elements
- text_011 - mixed character references in text
- text_012 - non-ASCII text
- tree_001 - all node types
- tree_002 - BOM
- tree_003 - Windows-1251 encoding
- tree_err_001 - no elements
- tree_err_002 - root element not closed
- tree_err_003 - child element not closed

View File

@@ -0,0 +1 @@
<p a='b'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: "b"

View File

@@ -0,0 +1,3 @@
<p a='
xyz'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: " xyz"

View File

@@ -0,0 +1 @@
<p a='A&#x20;B'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: "A B"

View File

@@ -0,0 +1 @@
<p a='&#xd;&#xd;A&#xa;&#xa;B&#xd;&#xa;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: "\r\rA\n\nB\r\n"

View File

@@ -0,0 +1,3 @@
<e a='
b
'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: e
attributes:
a: " b "

View File

@@ -0,0 +1 @@
<e a='&lt;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: e
attributes:
a: "<"

View File

@@ -0,0 +1 @@
<e a='b1' a='b2'/>

View File

@@ -0,0 +1 @@
error: "attribute 'a' at 1:11 is already defined"

View File

@@ -0,0 +1 @@
<e xmlns:n1='http://www.w3.org' xmlns:n2='http://www.w3.org' n1:a='b1' n2:a='b2'/>

View File

@@ -0,0 +1 @@
error: "attribute 'a' at 1:72 is already defined"

View File

@@ -0,0 +1,3 @@
<doc>
<![CDATA[<greeting>Hello, world!</greeting>]]>
</doc>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: doc
children:
- Text: "\n<greeting>Hello, world!</greeting>\n"

View File

@@ -0,0 +1,3 @@
<e><![CDATA[
<![CDATA[abc]]]>]&gt;<![CDATA[
]]></e>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: e
children:
- Text: "\n <![CDATA[abc]]>\n "

View File

@@ -0,0 +1,3 @@
<p>
<![CDATA[]]>
</p>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
children:
- Text: "\n \n"

View File

@@ -0,0 +1,7 @@
<p>
some
<p>
<![CDATA[long]]>
</p>
text
</p>

View File

@@ -0,0 +1,10 @@
Document:
- Element:
tag_name: p
children:
- Text: "\n some\n "
- Element:
tag_name: p
children:
- Text: "\n long\n "
- Text: "\n text\n"

View File

@@ -0,0 +1 @@
<p>T<![CDATA[e]]>x<![CDATA[t]]></p>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
children:
- Text: "Text"

View File

@@ -0,0 +1,5 @@
<svg>
<style><![CDATA[
text
]]></style>
</svg>

After

Width:  |  Height:  |  Size: 63 B

View File

@@ -0,0 +1,10 @@
Document:
- Element:
tag_name: svg
children:
- Text: "\n "
- Element:
tag_name: style
children:
- Text: "\n text\n "
- Text: "\n"

View File

@@ -0,0 +1,4 @@
<svg>
<style><![CDATA[some
long
text

After

Width:  |  Height:  |  Size: 61 B

View File

@@ -0,0 +1,10 @@
Document:
- Element:
tag_name: svg
children:
- Text: "\n "
- Element:
tag_name: style
children:
- Text: "some\nlong\ntext\n"
- Text: "\n"

View File

@@ -0,0 +1,3 @@
<!-- comment -->
<root/>
<!-- comment -->

View File

@@ -0,0 +1,5 @@
Document:
- Comment: " comment "
- Element:
tag_name: root
- Comment: " comment "

View File

@@ -0,0 +1,3 @@
<root>
<item>
</root>

View File

@@ -0,0 +1 @@
error: "expected 'item' tag, not 'root' at 3:1"

View File

@@ -0,0 +1,3 @@
<t:root xmlns:t='http://www.w3.org'>
<t:item>
</t:root>

View File

@@ -0,0 +1 @@
error: "expected 't:item' tag, not 't:root' at 3:1"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p '<p/>'>
]>
<root>&p;</root>

View File

@@ -0,0 +1,6 @@
Document:
- Element:
tag_name: root
children:
- Element:
tag_name: p

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY v 'b'>
]>
<p a='&v;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: "b"

View File

@@ -0,0 +1,6 @@
<!DOCTYPE test [
<!ENTITY d '&#xD;'>
<!ENTITY a '&#xA;'>
<!ENTITY da '&#xD;&#xA;'>
]>
<p a='&d;&d;A&a;&#x20;&a;B&da;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: " A B "

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY b 'text'>
]>
<p>&b;</p>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
children:
- Text: "text"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY b 'text'>
]>
<e/>

View File

@@ -0,0 +1,3 @@
Document:
- Element:
tag_name: e

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY b 'Some&#x20;text'>
]>
<p>&b;</p>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
children:
- Text: "Some text"

View File

@@ -0,0 +1,5 @@
<!DOCTYPE test [
<!ENTITY a '&b;'>
<!ENTITY b 'text'>
]>
<e a='&a;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: e
attributes:
a: "text"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p ' <p/> '>
]>
<root>&p;</root>

View File

@@ -0,0 +1,8 @@
Document:
- Element:
tag_name: root
children:
- Text: " "
- Element:
tag_name: p
- Text: " "

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p 'text<p/>text'>
]>
<root>&p;</root>

View File

@@ -0,0 +1,8 @@
Document:
- Element:
tag_name: root
children:
- Text: "text"
- Element:
tag_name: p
- Text: "text"

View File

@@ -0,0 +1,5 @@
<!DOCTYPE test [
<!ENTITY q 'b'>
<!ENTITY p '<p a="&q;"/>'>
]>
<root>&p;</root>

View File

@@ -0,0 +1,8 @@
Document:
- Element:
tag_name: root
children:
- Element:
tag_name: p
attributes:
a: "b"

View File

@@ -0,0 +1,9 @@
<!DOCTYPE test [
<!ENTITY d '&#xD;'>
<!ENTITY a '&#xA;'>
<!ENTITY da '&#xD;&#xA;'>
]>
<root>
<p a='&d;&d;A&a;&a;B&da;&da;'/>
<p a='&#xD;&#xD;A&#xA;&#xA;B&#xD;&#xA;&#xD;&#xA;'/>
</root>

View File

@@ -0,0 +1,15 @@
Document:
- Element:
tag_name: root
children:
- Text: "\n "
- Element:
tag_name: p
attributes:
a: " A B "
- Text: "\n "
- Element:
tag_name: p
attributes:
a: "\r\rA\n\nB\r\n\r\n"
- Text: "\n"

View File

@@ -0,0 +1,43 @@
<!DOCTYPE test [
<!ENTITY d '&#xD;'>
<!ENTITY a '&#xA;'>
<!ENTITY da '&#xD;&#xA;'>
]>
<root>
<p id="1">&a;</p>
<p id="2">&a;&a;</p>
<p id="3">&a;&a;&a;</p>
<p id="4">&d;</p>
<p id="5">&d;&d;</p>
<p id="6">&d;&d;&d;</p>
<p id="7">&a;&d;</p>
<p id="8">&d;&a;</p>
<p id="9">&a;&d;&a;</p>
<p id="10">&d;&a;&d;</p>
<p id="11">&a;q&a;</p>
<p id="12">&d;q&d;</p>
<p id="13">&a;q&d;</p>
<p id="14">&d;q&a;</p>
<p id="15">&a;&da;</p>
<p id="16">&da;&a;</p>
<p id="17">&d;&da;</p>
<p id="18">&da;&d;</p>
<p id="19">&da;&da;</p>
<p id="20">&a;&a;q</p>
<p id="21">q&a;&a;</p>
<p id="22">q&a;&a;q</p>
<p id="23">&d;&d;q</p>
<p id="24">q&d;&d;</p>
<p id="25">q&d;&d;q</p>
<p id="26">&da;&da;q</p>
<p id="27">q&da;&da;</p>
<p id="28">q&da;&da;q</p>
</root>

View File

@@ -0,0 +1,201 @@
Document:
- Element:
tag_name: root
children:
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "1"
children:
- Text: "\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "2"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "3"
children:
- Text: "\n\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "4"
children:
- Text: "\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "5"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "6"
children:
- Text: "\n\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "7"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "8"
children:
- Text: "\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "9"
children:
- Text: "\n\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "10"
children:
- Text: "\n\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "11"
children:
- Text: "\nq\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "12"
children:
- Text: "\nq\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "13"
children:
- Text: "\nq\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "14"
children:
- Text: "\nq\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "15"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "16"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "17"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "18"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "19"
children:
- Text: "\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "20"
children:
- Text: "\n\nq"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "21"
children:
- Text: "q\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "22"
children:
- Text: "q\n\nq"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "23"
children:
- Text: "\n\nq"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "24"
children:
- Text: "q\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "25"
children:
- Text: "q\n\nq"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "26"
children:
- Text: "\n\nq"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "27"
children:
- Text: "q\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "28"
children:
- Text: "q\n\nq"
- Text: "\n"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY q 'q'>
]>
<root>&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;</root>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: root
children:
- Text: "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY q 'q'>
]>
<root a="&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;"/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: root
attributes:
a: "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"

View File

@@ -0,0 +1 @@
<e a='&d;'/>

View File

@@ -0,0 +1 @@
error: "unknown entity reference 'd' at 1:7"

View File

@@ -0,0 +1,5 @@
<!DOCTYPE test [
<!ENTITY a '&b;'>
<!ENTITY b '&a;'>
]>
<e a='&a;'/>

View File

@@ -0,0 +1 @@
error: "a possible entity reference loop is detected at 3:20"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p '</p>'>
]>
<root>&p;</root>

View File

@@ -0,0 +1 @@
error: "unexpected close tag at 2:17"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p '</p>'>
]>
<root><p>&p;</root>

View File

@@ -0,0 +1 @@
error: "unexpected close tag at 2:17"

View File

@@ -0,0 +1,13 @@
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>

View File

@@ -0,0 +1 @@
error: "a possible entity reference loop is detected at 3:40"

View File

@@ -0,0 +1,13 @@
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz a="&lol9;"/>

View File

@@ -0,0 +1 @@
error: "a possible entity reference loop is detected at 3:40"

View File

@@ -0,0 +1 @@
<p a="&amp"/>

View File

@@ -0,0 +1 @@
error: "malformed entity reference at 1:7"

View File

@@ -0,0 +1 @@
<p>&amp</p>

View File

@@ -0,0 +1 @@
error: "malformed entity reference at 1:4"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY e "<p a='&lt;'/>">
]>
<e>&e;</e>

View File

@@ -0,0 +1 @@
error: "unescaped '<' found at 2:23"

View File

@@ -0,0 +1 @@
<e xmlns:n1='http://www.w3.org' xmlns='http://www.w3.org' n1:a='b1' a='b2'/>

View File

@@ -0,0 +1,9 @@
Document:
- Element:
tag_name: e@http://www.w3.org
attributes:
a: "b2"
a@http://www.w3.org: "b1"
namespaces:
None: http://www.w3.org
n1: http://www.w3.org

View File

@@ -0,0 +1 @@
<svg xmlns='http://www.w3.org/2000/svg' a='b'/>

After

Width:  |  Height:  |  Size: 48 B

View File

@@ -0,0 +1,7 @@
Document:
- Element:
tag_name: svg@http://www.w3.org/2000/svg
attributes:
a: "b"
namespaces:
None: http://www.w3.org/2000/svg

View File

@@ -0,0 +1 @@
<svg:svg xmlns:svg='http://www.w3.org/2000/svg' a='b' svg:a='b'/>

After

Width:  |  Height:  |  Size: 66 B

View File

@@ -0,0 +1,8 @@
Document:
- Element:
tag_name: svg@http://www.w3.org/2000/svg
attributes:
a: "b"
a@http://www.w3.org/2000/svg: "b"
namespaces:
svg: http://www.w3.org/2000/svg

View File

@@ -0,0 +1 @@
<svg xmlns:t='http://www.w3.org/1999/xlink' t:href='https://www.w3.org/TR/SVG11/'/>

After

Width:  |  Height:  |  Size: 84 B

View File

@@ -0,0 +1,7 @@
Document:
- Element:
tag_name: svg
attributes:
href@http://www.w3.org/1999/xlink: "https://www.w3.org/TR/SVG11/"
namespaces:
t: http://www.w3.org/1999/xlink

View File

@@ -0,0 +1 @@
<svg xml:space='preserve'/>

After

Width:  |  Height:  |  Size: 28 B

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: svg
attributes:
space@http://www.w3.org/XML/1998/namespace: "preserve"

View File

@@ -0,0 +1 @@
<svg xmlns:xml='http://www.w3.org/XML/1998/namespace' xml:space='preserve'/>

After

Width:  |  Height:  |  Size: 77 B

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: svg
attributes:
space@http://www.w3.org/XML/1998/namespace: "preserve"

View File

@@ -0,0 +1,2 @@
<e a:attr='a_ns' b:attr='b_ns' attr='no_ns' xmlns:b='http://www.ietf.org'
xmlns:a='http://www.w3.org' xmlns='http://www.uvic.ca'/>

View File

@@ -0,0 +1,11 @@
Document:
- Element:
tag_name: e@http://www.uvic.ca
attributes:
attr: "no_ns"
attr@http://www.ietf.org: "b_ns"
attr@http://www.w3.org: "a_ns"
namespaces:
None: http://www.uvic.ca
a: http://www.w3.org
b: http://www.ietf.org

Some files were not shown because too many files have changed in this diff Show More