jingle: Add an error when there is more than one <text/> in a <reason/>.
This commit is contained in:
parent
9da488f909
commit
9d129701d0
1 changed files with 12 additions and 1 deletions
|
@ -5,7 +5,7 @@ use std::str::FromStr;
|
|||
use minidom::Element;
|
||||
|
||||
use error::Error;
|
||||
use ns::{JINGLE_NS};
|
||||
use ns::JINGLE_NS;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Action {
|
||||
|
@ -285,6 +285,9 @@ pub fn parse_jingle(root: &Element) -> Result<Jingle, Error> {
|
|||
}
|
||||
let name = stuff.name();
|
||||
if name == "text" {
|
||||
if text.is_some() {
|
||||
return Err(Error::ParseError("Reason must not have more than one text."));
|
||||
}
|
||||
text = Some(stuff.text());
|
||||
} else {
|
||||
reason = Some(name.parse()?);
|
||||
|
@ -487,5 +490,13 @@ mod tests {
|
|||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Jingle must not have more than one reason.");
|
||||
|
||||
let elem: Element = "<jingle xmlns='urn:xmpp:jingle:1' action='session-initiate' sid='coucou'><reason><decline/><text/><text/></reason></jingle>".parse().unwrap();
|
||||
let error = jingle::parse_jingle(&elem).unwrap_err();
|
||||
let message = match error {
|
||||
Error::ParseError(string) => string,
|
||||
_ => panic!(),
|
||||
};
|
||||
assert_eq!(message, "Reason must not have more than one text.");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue