aboutsummaryrefslogtreecommitdiff
path: root/src/tokenizer.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-01 19:13:34 +0200
committerMartin Fischer <martin@push-f.com>2023-09-03 23:00:05 +0200
commitbbb00e4a029187ec9e0998639d3470f463c4a798 (patch)
tree62c31af085f6e6f62757568744ba29412cf9a4c7 /src/tokenizer.rs
parenta3f0d87fe4f4c21e09b981ffa72535fcdf9a78ae (diff)
fix: off-by-one eof error spans
Diffstat (limited to 'src/tokenizer.rs')
-rw-r--r--src/tokenizer.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index db4fda6..6cf930f 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -178,10 +178,16 @@ impl<R: Reader + Position<O>, O: Offset, E: Emitter<O>> Tokenizer<R, O, E> {
/// Just a helper method for the machine.
#[inline]
pub(crate) fn emit_error(&mut self, error: Error) {
- self.emitter.emit_error(
- error,
- self.reader.position() - 1..self.reader.position() - 1,
- );
+ let span = match error {
+ Error::EofBeforeTagName
+ | Error::EofInCdata
+ | Error::EofInComment
+ | Error::EofInDoctype
+ | Error::EofInScriptHtmlCommentLikeText
+ | Error::EofInTag => self.reader.position()..self.reader.position(),
+ _ => self.reader.position() - 1..self.reader.position() - 1,
+ };
+ self.emitter.emit_error(error, span);
}
/// Assuming the _current token_ is an end tag, return true if all of these hold. Return false otherwise.