Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@

### Bug Fixes

- [#624]: Fix corruption of parser state after cancelling of async reading.

### Misc Changes

[#624]: https://github.com/tafia/quick-xml/issues/624


## 0.39.0 -- 2026-01-11

Expand Down
11 changes: 8 additions & 3 deletions src/reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,15 @@ macro_rules! read_until_close {
$reader:expr
$(, $await:ident)?
) => {{
$self.state.state = ParseState::InsideText;

let start = $self.state.offset;
match $reader.peek_one() $(.$await)? {
// It is important to change state only after .await point, because future
// may be cancelled only at .await points
//
// See https://github.com/tafia/quick-xml/issues/624
let lookahead = $reader.peek_one() $(.$await)?;

$self.state.state = ParseState::InsideText;
match lookahead {
// `<!` - comment, CDATA or DOCTYPE declaration
Ok(Some(b'!')) => match $reader
.read_bang_element($buf, &mut $self.state.offset)
Expand Down