Skip to content

Commit

Permalink
Fix incorrect position reported for `Error::IllFormed(MissedDoctypeNa…
Browse files Browse the repository at this point in the history
…me)`

Fixed (6):
    ill_formed::missed_doctype_name1::async_tokio
    ill_formed::missed_doctype_name1::borrowed
    ill_formed::missed_doctype_name1::buffered
    ill_formed::missed_doctype_name2::async_tokio
    ill_formed::missed_doctype_name2::borrowed
    ill_formed::missed_doctype_name2::buffered
  • Loading branch information
Mingun committed Nov 21, 2023
1 parent 1755347 commit b20a77e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ configuration is serializable.

- [#622]: Fix wrong disregarding of not closed markup, such as lone `<`.
- [#684]: Fix incorrect position reported for `Error::IllFormed(DoubleHyphenInComment)`.
- [#684]: Fix incorrect position reported for `Error::IllFormed(MissedDoctypeName)`.

### Misc Changes

Expand Down
4 changes: 4 additions & 0 deletions src/reader/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ impl ReaderState {
.position(|b| !is_whitespace(*b))
.unwrap_or(len - 8);
if start + 8 >= len {
// Because we here, we at least read `<!DOCTYPE>` and offset after `>`.
// We want report error at place where name is expected - this is just
// before `>`
self.offset -= 1;
return Err(Error::IllFormed(IllFormedError::MissedDoctypeName));
}
Ok(Event::DocType(BytesText::wrap(
Expand Down

0 comments on commit b20a77e

Please sign in to comment.