tafia / quick-xml

Rust high performance xml reader and writer
MIT License
1.18k stars 235 forks source link

UnexpectedStart Error decoding xml that has a <br /> tag in it (fetched from a jenkins config.xml) #800

Closed merc1031 closed 1 month ago

merc1031 commented 1 month ago

I fetch a more complex config.xml from jenkins, and distilled it down to this test case.

simplified xml test_failing_description.xml

<?xml version="1.0" encoding="UTF-8"?><project>
    <description>
  <br/>
    Text
    </description>
</project>  

test

    #[rstest]
    fn test_failing_description() {
        #[derive(Debug, Deserialize)]
        #[serde(rename_all = "camelCase")]
        pub struct SimpleProject {
            pub description: String,
        }

        let d: PathBuf = [
            env!("CARGO_MANIFEST_DIR"),
            "test_resources",
            "jenkins",
            "xml",
            "job",
            "test_failing_description.xml",
        ]
        .iter()
        .collect();
        let xml = fs::read_to_string(d).expect("Unable to read file");
        let jd = &mut quick_xml::de::Deserializer::from_reader(xml.as_bytes());
        let job: SimpleProject = serde_path_to_error::deserialize(jd).unwrap();
        println!("{:?}", job);
    }

I get this error (using serde_path_to_error) called `Result::unwrap()` on an `Err` value: Error { path: Path { segments: [Map { key: "description" }] }, original: UnexpectedStart([98, 114]) }

similar issue in serde-xml-rs which i am migrating off of. https://github.com/RReverser/serde-xml-rs/issues/215

Mingun commented 1 month ago

Duplicate of #257.

merc1031 commented 1 month ago

@Mingun Sorry about that. I did try searching issues, just didnt notice that as duplicate.

thanks!