• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::reader::error::SyntaxError;
2 use crate::reader::events::XmlEvent;
3 use crate::reader::lexer::Token;
4 
5 use super::{PullParser, Result, State};
6 
7 impl PullParser {
inside_comment(&mut self, t: Token) -> Option<Result>8     pub fn inside_comment(&mut self, t: Token) -> Option<Result> {
9         match t {
10             Token::CommentEnd if self.config.c.ignore_comments => {
11                 self.into_state_continue(State::OutsideTag)
12             }
13 
14             Token::CommentEnd => {
15                 let data = self.take_buf();
16                 self.into_state_emit(State::OutsideTag, Ok(XmlEvent::Comment(data)))
17             }
18 
19             Token::Character(c) if !self.is_valid_xml_char(c) => {
20                 Some(self.error(SyntaxError::InvalidCharacterEntity(c as u32)))
21             },
22 
23             _ if self.config.c.ignore_comments => None, // Do not modify buffer if ignoring the comment
24 
25             _ => {
26                 if self.buf.len() > self.config.max_data_length {
27                     return Some(self.error(SyntaxError::ExceededConfiguredLimit));
28                 }
29                 t.push_to_string(&mut self.buf);
30                 None
31             }
32         }
33     }
34 }
35