diff --git a/parsers/src/stanza_error.rs b/parsers/src/stanza_error.rs index 2b53cd5..5cd4645 100644 --- a/parsers/src/stanza_error.rs +++ b/parsers/src/stanza_error.rs @@ -262,7 +262,7 @@ impl TryFrom for StanzaError { 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); + let lang = get_attr!(child, "xml:lang", Default); if stanza_error.texts.insert(lang, child.text()).is_some() { return Err(Error::ParseError( "Text element present twice for the same xml:lang.", @@ -396,6 +396,19 @@ mod tests { let elem: Element = r#" The feature requested is not implemented by the recipient or server and therefore cannot be processed. +"# + .parse() + .unwrap(); + let stanza_error = StanzaError::try_from(elem).unwrap(); + assert_eq!(stanza_error.type_, ErrorType::Cancel); + } + + #[test] + fn test_error_multiple_text() { + let elem: Element = r#" + + Nœud non trouvé + Node not found "# .parse() .unwrap();