Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BytesStart unescaped method returns the attributes in the same result #118

Closed
MarkDDR opened this issue Mar 3, 2018 · 1 comment · Fixed by #400
Closed

BytesStart unescaped method returns the attributes in the same result #118

MarkDDR opened this issue Mar 3, 2018 · 1 comment · Fixed by #400
Labels

Comments

@MarkDDR
Copy link
Contributor

MarkDDR commented Mar 3, 2018

If you had for example the following xml snippet <namespace:hello&gt; greeting='wave'> and the corresponding BytesStart for that, (let's called the element), element.unescaped() would return namespace:hello> greeting='wave', while .name() and local_name() only include the actual tag part (namespace:hello&gt; and hello&gt; respectively), and not the attributes.

This goes against the documentation which says it should just return the unescaped tag name.

@e00E
Copy link

e00E commented Dec 6, 2020

This is still broken:

#[test]
fn test() {
    let xml = "<name attribute=\"value\">";
    let mut reader = quick_xml::Reader::from_str(xml);
    reader.trim_text(true);
    let mut buf = Vec::new();
    let start_event = match reader.read_event(&mut buf).unwrap() {
        Event::Start(e) => e,
        _ => unreachable!(),
    };

    let raw_name_bytes = start_event.name();
    let raw_name = std::str::from_utf8(raw_name_bytes).unwrap();
    // ok
    assert_eq!(raw_name, "name");

    let name_bytes = start_event.unescaped().unwrap();
    let name = std::str::from_utf8(name_bytes.as_ref()).unwrap();
    // fails
    assert_eq!(name, "name");
}

thread 'test' panicked at 'assertion failed: (left == right)
left: "name attribute=\"value\"",
right: "name"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants