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

Serde deserialization: Namespaces can lead to erroneous "duplicate field" errors #547

Closed
roblabla opened this issue Jan 27, 2023 · 2 comments
Labels
namespaces Issues related to namespaces support serde Issues related to mapping from Rust types to XML

Comments

@roblabla
Copy link

roblabla commented Jan 27, 2023

There appears to be a bug when trying to deserialize XML mixing named and unnamed namespaces (e.g. xmlns=a and xmlns:a=a). Here's a quick repro, which I think shows the problem better than I can explain it:

#[test]
fn repro() {
    #[derive(Deserialize)]
    struct Root {
        lol: Vec<Lol>
    }

    #[derive(Deserialize)]
    struct Lol {}

    let x: Root = quick_xml::de::from_str(r#"<root>
        <lol xmlns="http://whatever.com/schema/whatever" />
        <ohai:lol xmlns:ohai="http://whatever.com/schema/whatever" />
    </root>"#).unwrap();
}

Output:

---- test::repro stdout ----
thread 'test::repro' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("duplicate field `lol`")', src/lib.rs:163:179
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I would expect both lol and ohai:lol to get appended to the lol: Vec<Lol> of the Root struct.

@roblabla
Copy link
Author

Changing TagFilter::is_suitable to compare local_name instead of the full name fixes my issue, though I'm not sure it's an acceptable general-purpose fix.

@Mingun Mingun added serde Issues related to mapping from Rust types to XML namespaces Issues related to namespaces support labels Jan 27, 2023
@Mingun
Copy link
Collaborator

Mingun commented Jan 27, 2023

Thanks for report, this is duplicate of #218

@Mingun Mingun closed this as not planned Won't fix, can't repro, duplicate, stale Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
namespaces Issues related to namespaces support serde Issues related to mapping from Rust types to XML
Projects
None yet
Development

No branches or pull requests

2 participants