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:
Maxime “pep” Buquet 2023-01-12 21:02:48 +01:00
parent 98174ec66b
commit 6bdc20bc53

View file

@ -4,7 +4,7 @@
// 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/.
use std::collections::HashMap;
use std::collections::{BTreeMap, HashMap};
use std::str::FromStr;
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 SCANSION_NS: &'static str = "https://matthewwild.co.uk/projects/scansion";
pub type AccountName = String;
@ -247,9 +248,12 @@ fn parse_send_receive<'a>(tagname: &str, name: String, s: Span<'a>) -> IResult<S
))(s)?;
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 =
Element::from_reader_with_prefixes(&lines.as_bytes()[..], String::from(DEFAULT_NS))
.unwrap();
Element::from_reader_with_prefixes(&lines.as_bytes()[..], prefixes).unwrap();
Ok(match tagname {
"sends:" => (s, Action::Send(name, elem)),
"receives:" => (s, Action::Receive(name, elem)),