aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-09-01 19:47:42 +0200
committerMartin Fischer <martin@push-f.com>2023-09-03 23:00:05 +0200
commit5d91c0cca7e8f453e0e2f36c57e9ad85ee8ab124 (patch)
tree4263bbd4c9cbd20a6455d1c7af45cb4cbd32dcf5
parent63f945e568c0710e3a97cddaa6264e85d86faa79 (diff)
fix: off-by-one missing-semicolon-after-character-reference span
-rw-r--r--CHANGELOG.md3
-rw-r--r--src/tokenizer.rs5
-rw-r--r--tests/test_spans.rs2
3 files changed, 7 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 13d3cf3..61d8138 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -42,7 +42,8 @@
* Fixed most error spans mistakenly being empty.
* Fixed some error spans being off-by-one
- (`eof-*`, `end-tag-with-trailing-solidus`).
+ (`eof-*`, `end-tag-with-trailing-solidus`,
+ `missing-semicolon-after-character-reference`).
### 0.5.0 - 2023-08-19
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index 871074e..f76cad8 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -184,7 +184,10 @@ impl<R: Reader + Position<O>, O: Offset, E: Emitter<O>> Tokenizer<R, O, E> {
| Error::EofInComment
| Error::EofInDoctype
| Error::EofInScriptHtmlCommentLikeText
- | Error::EofInTag => self.reader.position()..self.reader.position(),
+ | Error::EofInTag
+ | Error::MissingSemicolonAfterCharacterReference => {
+ self.reader.position()..self.reader.position()
+ }
_ => self.reader.position() - 1..self.reader.position(),
};
self.emitter.emit_error(error, span);
diff --git a/tests/test_spans.rs b/tests/test_spans.rs
index 560fe0e..0956f8e 100644
--- a/tests/test_spans.rs
+++ b/tests/test_spans.rs
@@ -249,7 +249,7 @@ fn error_char_ref_missing_semicolon() {
let html = "&not";
assert_snapshot!(annotate_errors(html), @r###"
&not
- ^ missing-semicolon-after-character-reference
+ ^ missing-semicolon-after-character-reference
"###);
}