Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic on wrongly closed elements #447

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
working on it
  • Loading branch information
vporton committed Jul 25, 2021
commit 9c3659482be7cf7bf21438a956958cefb762da6d
18 changes: 9 additions & 9 deletions html5ever/src/tree_builder/mod.rs
Original file line number Diff line number Diff line change
@@ -647,29 +647,29 @@ where

/// Indicate that a node was popped off the stack of open elements.
#[cfg(api_v2)]
fn current_node(&mut self, node: &Self::Handle) -> Option<&Handle> {
self.current_node_v2(node)
fn current_node(&self) -> Option<&Handle> {
self.current_node_v2()
}

/// Indicate that a node was popped off the stack of open elements.
#[cfg(not(api_v2))]
#[deprecated(note = "You are using an outdated API. Please use api_v2 feature.")]
fn current_node(&mut self, node: &Handle) -> &Handle {
self.current_node_unconditional(node)
fn current_node(&self) -> &Handle {
self.current_node_unconditional()
}

/// Like pop(), but in the case of no open element, just warn instead of returning an error.
fn current_node_unconditional(&mut self, node: &Handle) -> &Handle {
let current = self.current_node(node);
if self.current_node_v2(node).is_none() {
fn current_node_unconditional(&self) -> &Handle {
let current = self.current_node();
if self.current_node_v2().is_none() {
warn!("no current element");
}
current
}

/// Note: Don't use this function, use pop() with api_v2 feature instead.
fn current_node_v2(&mut self, node: &Self::Handle) -> Option<&Handle> {
self.open_elems.last(node)
fn current_node_v2(&self) -> Option<&Handle> {
self.open_elems.last()
}

fn adjusted_current_node(&self) -> &Handle {