mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
element: Fix element name comparison in from_reader
quick-xml's Events seem to always return prefixed names, and the from_reader function, when comparing name of the pop-ed element, and received event element, was using the unprefixed name to compare.
This commit is contained in:
parent
4685becf84
commit
1c3a701d2e
1 changed files with 10 additions and 1 deletions
|
@ -191,6 +191,11 @@ impl Element {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a reference to the prefix of this element.
|
||||||
|
pub fn prefix(&self) -> Option<String> {
|
||||||
|
self.prefix.clone()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a reference to the namespace of this element, if it has one, else `None`.
|
/// Returns a reference to the namespace of this element, if it has one, else `None`.
|
||||||
pub fn ns(&self) -> Option<String> {
|
pub fn ns(&self) -> Option<String> {
|
||||||
self.namespaces.get(&self.prefix)
|
self.namespaces.get(&self.prefix)
|
||||||
|
@ -318,7 +323,11 @@ impl Element {
|
||||||
}
|
}
|
||||||
let elem = stack.pop().unwrap();
|
let elem = stack.pop().unwrap();
|
||||||
if let Some(to) = stack.last_mut() {
|
if let Some(to) = stack.last_mut() {
|
||||||
if elem.name().as_bytes() != e.name() {
|
let name = match elem.prefix() {
|
||||||
|
Some(ref prefix) => format!("{}:", prefix.clone()),
|
||||||
|
None => String::from(""),
|
||||||
|
} + elem.name();
|
||||||
|
if name.as_bytes() != e.name() {
|
||||||
bail!(ErrorKind::InvalidElementClosed);
|
bail!(ErrorKind::InvalidElementClosed);
|
||||||
}
|
}
|
||||||
to.append_child(elem);
|
to.append_child(elem);
|
||||||
|
|
Loading…
Reference in a new issue