-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Labels
Description
This may be a bug in libxml itself, but if you call set_content with an ampersand (&) that isn't & it treats it at an entity, and if that entity is unknown/invalid, it will print out "error: unterminated entity reference" on stderr, and will set the node content to blank string. The concerning thing is that set_content is not returning Err.
libxml = "0.3"
use libxml::tree::*;
fn main() {
// induce set content bug in set_content
let mut d = Document::new().unwrap();
let mut n = Node::new("span", None, &d).unwrap();
n.set_content("Testing").unwrap();
let s = n.get_content();
assert_eq!(s, "Testing");
n.set_content("Testing & Breaking").unwrap();
let s = n.get_content();
assert_eq!(s, "Testing & Breaking");
}
output:
Running `target/debug/ctest`
error : unterminated entity reference Breaking
thread 'main' panicked at src/main.rs:15:5:
assertion `left == right` failed
left: ""
right: "Testing & Breaking"