wip: Strict deserialization returns error on any unknown xml field or attribute
This commit is contained in:
parent
5cd09186fa
commit
353558737f
@ -1117,3 +1117,20 @@ fn de_nested_macro_rules() {
|
|||||||
|
|
||||||
float_attrs!(f32);
|
float_attrs!(f32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn de_strict() {
|
||||||
|
init();
|
||||||
|
|
||||||
|
#[derive(PartialEq, Debug, YaDeserialize)]
|
||||||
|
pub struct Struct {
|
||||||
|
id: i32,
|
||||||
|
}
|
||||||
|
let xml_content = r#"<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Struct>
|
||||||
|
<id>123</id>
|
||||||
|
<NonExistentAttrShouldCrash></NonExistentAttrShouldCrash>
|
||||||
|
</Struct>"#;
|
||||||
|
let load: Result<Struct, String> = from_str(xml_content);
|
||||||
|
assert!(load.is_err());
|
||||||
|
}
|
||||||
|
@ -431,6 +431,9 @@ pub fn parse(
|
|||||||
match (namespace.as_str(), name.local_name.as_str()) {
|
match (namespace.as_str(), name.local_name.as_str()) {
|
||||||
#call_visitors
|
#call_visitors
|
||||||
_ => {
|
_ => {
|
||||||
|
::yaserde::__derive_trace!("SKIPPINGSKIPPING Skipping element {:?}", name.local_name);
|
||||||
|
return Err(format!("Found unauthorized element {}", name.local_name));
|
||||||
|
|
||||||
let event = reader.next_event()?;
|
let event = reader.next_event()?;
|
||||||
#write_unused
|
#write_unused
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user