Provide scansion namespace for minidom::Element
It went undetected until now as these attributes only seem to be on child elements which aren't parsed yet. Not having this NS available should cause issues though when the user explores the element. Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
98174ec66b
commit
6bdc20bc53
1 changed files with 7 additions and 3 deletions
10
src/lib.rs
10
src/lib.rs
|
@ -4,7 +4,7 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::{BTreeMap, HashMap};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
@ -41,6 +41,7 @@ impl<'a> From<NomErr<nom::error::Error<LocatedSpan<&'a str>>>> for Token<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static DEFAULT_NS: &'static str = "jabber:client";
|
pub static DEFAULT_NS: &'static str = "jabber:client";
|
||||||
|
pub static SCANSION_NS: &'static str = "https://matthewwild.co.uk/projects/scansion";
|
||||||
|
|
||||||
pub type AccountName = String;
|
pub type AccountName = String;
|
||||||
|
|
||||||
|
@ -247,9 +248,12 @@ fn parse_send_receive<'a>(tagname: &str, name: String, s: Span<'a>) -> IResult<S
|
||||||
))(s)?;
|
))(s)?;
|
||||||
let lines = lines.trim();
|
let lines = lines.trim();
|
||||||
|
|
||||||
|
// Namespaces
|
||||||
|
let mut prefixes = BTreeMap::new();
|
||||||
|
prefixes.insert(None, String::from(DEFAULT_NS));
|
||||||
|
prefixes.insert(Some(String::from("scansion")), String::from(SCANSION_NS));
|
||||||
let elem: Element =
|
let elem: Element =
|
||||||
Element::from_reader_with_prefixes(&lines.as_bytes()[..], String::from(DEFAULT_NS))
|
Element::from_reader_with_prefixes(&lines.as_bytes()[..], prefixes).unwrap();
|
||||||
.unwrap();
|
|
||||||
Ok(match tagname {
|
Ok(match tagname {
|
||||||
"sends:" => (s, Action::Send(name, elem)),
|
"sends:" => (s, Action::Send(name, elem)),
|
||||||
"receives:" => (s, Action::Receive(name, elem)),
|
"receives:" => (s, Action::Receive(name, elem)),
|
||||||
|
|
Loading…
Reference in a new issue