Skip to content

Commit 7967765

Browse files
authored
Ensure that TagScanner::is_in_end_tag resets when changing parsers. (#192)
* Ensure that `TagScanner::is_in_end_tag` resets when changing parsers. * Release 1.1.1.
1 parent 56f17ce commit 7967765

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v1.1.1
4+
5+
### Fixed
6+
7+
- Ensure that `TagScanner::is_in_end_tag` resets when changing parsers.
8+
39
## v1.1.0
410

511
### Added

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lol_html"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
authors = ["Ivan Nikulin <inikulin@cloudflare.com, ifaaan@gmail.com>"]
55
license = "BSD-3-Clause"
66
description = "Streaming HTML rewriter/parser with CSS selector-based API"

c-api/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lolhtml"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
authors = ["Ivan Nikulin <inikulin@cloudflare.com>", "Joshua Nelson <jnelson@cloudflare.com>"]
55
edition = "2021"
66

js-api/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lol-html-js-api"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
authors = ["Ivan Nikulin <inikulin@cloudflare.com>"]
55
edition = "2021"
66

src/parser/tag_scanner/actions.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ impl<S: TagHintSink> StateMachineActions for TagScanner<S> {
4545
.try_apply_tree_builder_feedback()
4646
.map_err(ActionError::from)?;
4747

48+
let is_in_end_tag = self.is_in_end_tag;
49+
50+
self.is_in_end_tag = false;
51+
4852
if let Some(unhandled_feedback) = unhandled_feedback {
4953
return self.change_parser_directive(
5054
tag_start,
@@ -54,7 +58,7 @@ impl<S: TagHintSink> StateMachineActions for TagScanner<S> {
5458
}
5559

5660
match self
57-
.emit_tag_hint(input)
61+
.emit_tag_hint(input, is_in_end_tag)
5862
.map_err(ActionError::RewritingError)?
5963
{
6064
ParserDirective::WherePossibleScanForTagsOnly => Ok(()),

src/parser/tag_scanner/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ impl<S: TagHintSink> TagScanner<S> {
7979
}
8080
}
8181

82-
fn emit_tag_hint(&mut self, input: &[u8]) -> Result<ParserDirective, RewritingError> {
82+
fn emit_tag_hint(
83+
&mut self,
84+
input: &[u8],
85+
is_in_end_tag: bool,
86+
) -> Result<ParserDirective, RewritingError> {
8387
let name_range = Range {
8488
start: self.tag_name_start,
8589
end: self.pos(),
@@ -90,8 +94,7 @@ impl<S: TagHintSink> TagScanner<S> {
9094

9195
trace!(@output name);
9296

93-
if self.is_in_end_tag {
94-
self.is_in_end_tag = false;
97+
if is_in_end_tag {
9598
self.tag_hint_sink.handle_end_tag_hint(name)
9699
} else {
97100
self.last_start_tag_name_hash = self.tag_name_hash;

0 commit comments

Comments
 (0)