Skip to content

Commit c00bbc1

Browse files
committed
Add regression test for deserializing list attributes that requires decoding
failures: issue888
1 parent 6a6d23c commit c00bbc1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/serde-issues.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,3 +674,38 @@ fn issue868() {
674674
),
675675
}
676676
}
677+
678+
/// Regression test for https://github.com/tafia/quick-xml/pull/888.
679+
#[cfg(feature = "encoding")]
680+
#[test]
681+
fn issue888() {
682+
#[derive(Debug, PartialEq, Deserialize)]
683+
struct Root {
684+
#[serde(rename = "@list")]
685+
list: Vec<String>,
686+
}
687+
688+
let xml = r#"
689+
<?xml version="1.0" encoding="windows-1251"?>
690+
<root list="текст требующий декодирования"/>"#;
691+
692+
let (xml, enc, _) = dbg!(encoding_rs::WINDOWS_1251.encode(xml));
693+
assert_eq!(
694+
enc,
695+
encoding_rs::WINDOWS_1251,
696+
"windows-1251 should be used for the test"
697+
);
698+
699+
let data: Root = quick_xml::de::from_reader(xml.as_ref()).unwrap();
700+
assert_eq!(
701+
data,
702+
Root {
703+
list: vec![
704+
// Translation from Russian:
705+
"текст".to_string(), // text
706+
"требующий".to_string(), // that-requires
707+
"декодирования".to_string(), // decoding
708+
],
709+
}
710+
);
711+
}

0 commit comments

Comments
 (0)