Skip to content

Attribute list parsing with serde does not treat \t as separator #674

Open
@reknih

Description

Deserialization of a list in an attribute value does not treat the tab character as a separator, despite the documentation stating that it should.

use quick_xml::de::Deserializer;
use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Any {
    #[serde(rename = "@list")]
    list: Vec<Item>,
}

#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "lowercase")]
enum Item {
    Foo,
    Bar,
}

#[test]
fn main() {
    // The separator between the two characters is a tab.
    let str = r#"<any list="foo	bar" />"#;
    let mut deser = Deserializer::from_str(str);
    let any = Any::deserialize(&mut deser).unwrap();
    assert_eq!(any.list, vec![Item::Foo, Item::Bar]);
}

Expected behavior: The assertion passes.
Actual behavior: thread 'main' panicked at 'called Result::unwrap() on an Err value: Custom("unknown variant foo\tbar, expected foo or bar")'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arraysIssues related to mapping XML content onto arrays using serdebughelp wantedserdeIssues related to mapping from Rust types to XML

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions