-
Notifications
You must be signed in to change notification settings - Fork 269
Open
Labels
enhancementhelp wantedserdeIssues related to mapping from Rust types to XMLIssues related to mapping from Rust types to XML
Description
When a file defines new entities into its DOCTYPE, quick-xml does not recognize these entities in attribute values or text nodes. This causes an EscapeError(UnrecognizedSymbol(...)) error.
I built a minimal example demonstrating this problem...
use quick_xml::Reader;
use quick_xml::events::Event;
const DATA: &str = r#"
<?xml version="1.0"?>
<!DOCTYPE test [
<!ENTITY msg "hello world" >
]>
<test label="&msg;">&msg;</test>
"#;
fn main() {
let mut reader = Reader::from_str(DATA);
reader.trim_text(true);
let mut buf = Vec::new();
loop {
match reader.read_event(&mut buf) {
Ok(Event::Start(ref e)) => {
match e.name() {
b"test" => println!("attributes values: {:?}",
e.attributes().map(|a| a.unwrap().unescape_and_decode_value(&reader).unwrap())
.collect::<Vec<_>>()),
_ => (),
}
},
Ok(Event::Text(ref e)) => {
println!("text value: {}", e.unescape_and_decode(&reader).unwrap());
},
Ok(Event::Eof) => break,
Err(e) => panic!("Error at position {}: {:?}", reader.buffer_position(), e),
_ => (),
}
}
}I wasn't sure if that was a dublicate of #124 because that issue is about external entities...
Metadata
Metadata
Assignees
Labels
enhancementhelp wantedserdeIssues related to mapping from Rust types to XMLIssues related to mapping from Rust types to XML