From fb4a3dcba86a48073fc15e6160fbafe78c3d497f Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 28 Feb 2019 02:48:50 +0100 Subject: [PATCH] stanza_error: Add missing attribute checks. --- src/stanza_error.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/stanza_error.rs b/src/stanza_error.rs index fdc0d52..fd0522d 100644 --- a/src/stanza_error.rs +++ b/src/stanza_error.rs @@ -240,6 +240,7 @@ impl TryFrom for StanzaError { fn try_from(elem: Element) -> Result { check_self!(elem, "error", DEFAULT_NS); + check_no_unknown_attributes!(elem, "error", ["type", "by"]); let type_ = get_attr!(elem, "type", Required); let by = get_attr!(elem, "by", Option); @@ -250,6 +251,7 @@ impl TryFrom for StanzaError { for child in elem.children() { if child.is("text", ns::XMPP_STANZAS) { check_no_children!(child, "text"); + check_no_unknown_attributes!(child, "text", ["xml:lang"]); let lang = get_attr!(elem, "xml:lang", Default); if texts.insert(lang, child.text()).is_some() { return Err(Error::ParseError( @@ -263,6 +265,7 @@ impl TryFrom for StanzaError { )); } check_no_children!(child, "defined-condition"); + check_no_attributes!(child, "defined-condition"); let condition = DefinedCondition::try_from(child.clone())?; defined_condition = Some(condition); } else {