summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2023-08-30 09:50:53 +0200
committerMartin Fischer <martin@push-f.com>2023-09-03 23:00:05 +0200
commit585c6349c9b84345364350f020e8f987a8b44f7b (patch)
tree8e8facc1a222f7fa134034f429938654c7fb9884 /src
parent854e55cd8577baa24a2f3bd00e4ed8687e150f36 (diff)
fix!: off-by-one end-tag-with-trailing-solidus span
Diffstat (limited to 'src')
-rw-r--r--src/emitter.rs9
-rw-r--r--src/machine.rs2
2 files changed, 7 insertions, 4 deletions
diff --git a/src/emitter.rs b/src/emitter.rs
index d28b11b..9334121 100644
--- a/src/emitter.rs
+++ b/src/emitter.rs
@@ -89,7 +89,7 @@ pub trait Emitter<O> {
///
/// If the current token is an end tag, the emitter should emit the
/// [`Error::EndTagWithTrailingSolidus`] error.
- fn set_self_closing(&mut self, offset: O);
+ fn set_self_closing(&mut self, slash_offset: O);
/// Assuming the _current token_ is a doctype, set its "force quirks" flag to true.
///
@@ -329,7 +329,7 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
self.emit_token(Token::Doctype(doctype));
}
- fn set_self_closing(&mut self, offset: O) {
+ fn set_self_closing(&mut self, slash_offset: O) {
let tag = self.current_token.as_mut().unwrap();
match tag {
Token::StartTag(StartTag {
@@ -339,7 +339,10 @@ impl<O: Offset> Emitter<O> for DefaultEmitter<O> {
*self_closing = true;
}
Token::EndTag(_) => {
- self.emit_error(Error::EndTagWithTrailingSolidus, offset - 1..offset);
+ self.emit_error(
+ Error::EndTagWithTrailingSolidus,
+ slash_offset..slash_offset + 1,
+ );
}
_ => {
debug_assert!(false);
diff --git a/src/machine.rs b/src/machine.rs
index 159a8a0..082ab68 100644
--- a/src/machine.rs
+++ b/src/machine.rs
@@ -903,7 +903,7 @@ where
},
State::SelfClosingStartTag => match slf.read_char()? {
Some('>') => {
- slf.emitter.set_self_closing(slf.reader.position());
+ slf.emitter.set_self_closing(slf.reader.position() - 2);
slf.state = State::Data;
slf.emit_current_tag();
Ok(ControlToken::Continue)