From 10a336f8749817db0e507a42711500bd7c79e3b0 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Fri, 28 Apr 2017 23:45:27 +0100 Subject: [PATCH] jingle: Accept any unknown child, as per the specification. --- src/jingle.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/jingle.rs b/src/jingle.rs index 800cb7aee03daa01b4236fe6232f7169ed8364a5..1437207034ba2d8794a1d66e7d1da61e6b59f931 100644 --- a/src/jingle.rs +++ b/src/jingle.rs @@ -239,7 +239,7 @@ pub struct Jingle { pub sid: String, pub contents: Vec, pub reason: Option, - //pub other: Vec, + pub other: Vec, } pub fn parse_jingle(root: &Element) -> Result { @@ -259,6 +259,7 @@ pub fn parse_jingle(root: &Element) -> Result { let sid = root.attr("sid") .ok_or(Error::ParseError("Jingle must have a 'sid' attribute."))?; let mut reason_element = None; + let mut other = vec!(); for child in root.children() { if child.is("content", ns::JINGLE) { @@ -359,7 +360,7 @@ pub fn parse_jingle(root: &Element) -> Result { text: text, }); } else { - return Err(Error::ParseError("Unknown element in jingle.")); + other.push(child.clone()); } } @@ -370,6 +371,7 @@ pub fn parse_jingle(root: &Element) -> Result { sid: sid.to_owned(), contents: contents, reason: reason_element, + other: other, }) } @@ -451,14 +453,6 @@ mod tests { _ => panic!(), }; assert_eq!(message, "Unknown action."); - - let elem: Element = "".parse().unwrap(); - let error = jingle::parse_jingle(&elem).unwrap_err(); - let message = match error { - Error::ParseError(string) => string, - _ => panic!(), - }; - assert_eq!(message, "Unknown element in jingle."); } #[test]