Skip to content

Commit

Permalink
Ensure that TagScanner::is_in_end_tag resets when changing parsers. (
Browse files Browse the repository at this point in the history
…#192)

* Ensure that `TagScanner::is_in_end_tag` resets when changing parsers.

* Release 1.1.1.
  • Loading branch information
orium committed Jul 31, 2023
1 parent 56f17ce commit 7967765
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.1.1

### Fixed

- Ensure that `TagScanner::is_in_end_tag` resets when changing parsers.

## v1.1.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lol_html"
version = "1.1.0"
version = "1.1.1"
authors = ["Ivan Nikulin <inikulin@cloudflare.com, ifaaan@gmail.com>"]
license = "BSD-3-Clause"
description = "Streaming HTML rewriter/parser with CSS selector-based API"
Expand Down
2 changes: 1 addition & 1 deletion c-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lolhtml"
version = "1.1.0"
version = "1.1.1"
authors = ["Ivan Nikulin <inikulin@cloudflare.com>", "Joshua Nelson <jnelson@cloudflare.com>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion js-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lol-html-js-api"
version = "1.1.0"
version = "1.1.1"
authors = ["Ivan Nikulin <inikulin@cloudflare.com>"]
edition = "2021"

Expand Down
6 changes: 5 additions & 1 deletion src/parser/tag_scanner/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ impl<S: TagHintSink> StateMachineActions for TagScanner<S> {
.try_apply_tree_builder_feedback()
.map_err(ActionError::from)?;

let is_in_end_tag = self.is_in_end_tag;

self.is_in_end_tag = false;

if let Some(unhandled_feedback) = unhandled_feedback {
return self.change_parser_directive(
tag_start,
Expand All @@ -54,7 +58,7 @@ impl<S: TagHintSink> StateMachineActions for TagScanner<S> {
}

match self
.emit_tag_hint(input)
.emit_tag_hint(input, is_in_end_tag)
.map_err(ActionError::RewritingError)?
{
ParserDirective::WherePossibleScanForTagsOnly => Ok(()),
Expand Down
9 changes: 6 additions & 3 deletions src/parser/tag_scanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ impl<S: TagHintSink> TagScanner<S> {
}
}

fn emit_tag_hint(&mut self, input: &[u8]) -> Result<ParserDirective, RewritingError> {
fn emit_tag_hint(
&mut self,
input: &[u8],
is_in_end_tag: bool,
) -> Result<ParserDirective, RewritingError> {
let name_range = Range {
start: self.tag_name_start,
end: self.pos(),
Expand All @@ -90,8 +94,7 @@ impl<S: TagHintSink> TagScanner<S> {

trace!(@output name);

if self.is_in_end_tag {
self.is_in_end_tag = false;
if is_in_end_tag {
self.tag_hint_sink.handle_end_tag_hint(name)
} else {
self.last_start_tag_name_hash = self.tag_name_hash;
Expand Down

0 comments on commit 7967765

Please sign in to comment.