Skip to content

Commit 78e1360

Browse files
committed
Fix pos when trimming whitespace in cdata
Fixes #29
1 parent 30d4635 commit 78e1360

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/reader/parser/outside_tag.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ impl PullParser {
8080

8181
Token::CDataStart if self.depth() > 0 && self.config.c.coalesce_characters && self.config.c.cdata_to_characters => {
8282
if self.buf.is_empty() {
83-
self.push_pos();
83+
self.push_pos(); // CDataEnd will pop pos if the buffer remains empty
8484
}
85+
// if coalescing chars, continue without event
8586
self.into_state_continue(State::InsideCData)
8687
},
8788

@@ -91,6 +92,8 @@ impl PullParser {
9192
let mut next_event = if self.buf_has_data() {
9293
let buf = self.take_buf();
9394
if self.inside_whitespace && self.config.c.trim_whitespace {
95+
// there will be no event emitted for this, but start of buffering has pushed a pos
96+
self.next_pos();
9497
None
9598
} else if self.inside_whitespace && !self.config.c.whitespace_to_characters {
9699
debug_assert!(buf.chars().all(|ch| ch.is_whitespace()), "ws={buf:?}");

0 commit comments

Comments
 (0)