minidom: Remove comments support. Forbid them as per XMPP RFC.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2020-03-26 19:50:34 +01:00
commit 015d0007fc
No known key found for this signature in database
GPG key ID: DEDA74AEECA9D0F2
5 changed files with 13 additions and 76 deletions

View file

@ -335,12 +335,9 @@ impl Element {
Event::Eof => {
return Err(Error::EndOfDocument);
}
#[cfg(not(feature = "comments"))]
Event::Comment { .. } => {
return Err(Error::CommentsDisabled);
return Err(Error::NoComments);
}
#[cfg(feature = "comments")]
Event::Comment { .. } => (),
Event::Text { .. }
| Event::End { .. }
| Event::CData { .. }
@ -418,16 +415,7 @@ impl Element {
Event::Eof => {
break;
}
#[cfg(not(feature = "comments"))]
Event::Comment(_) => return Err(Error::CommentsDisabled),
#[cfg(feature = "comments")]
Event::Comment(s) => {
let comment = reader.decode(&s)?.to_owned();
if comment != "" {
let current_elem = stack.last_mut().unwrap();
current_elem.append_comment_node(comment);
}
}
Event::Comment(_) => return Err(Error::NoComments),
Event::Decl { .. } | Event::PI { .. } | Event::DocType { .. } => (),
}
}
@ -632,22 +620,6 @@ impl Element {
self.children.push(Node::Text(child.into()));
}
/// Appends a comment node to an `Element`.
///
/// # Examples
///
/// ```rust
/// use minidom::Element;
///
/// let mut elem = Element::bare("node");
///
/// elem.append_comment_node("comment");
/// ```
#[cfg(feature = "comments")]
pub fn append_comment_node<S: Into<String>>(&mut self, child: S) {
self.children.push(Node::Comment(child.into()));
}
/// Appends a node to an `Element`.
///
/// # Examples