Skip to content

Commit 70d167a

Browse files
committed
Drop blocked nodes instead of leaking their text
1 parent dd74b66 commit 70d167a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

crates/parser/src/html/converter.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn convert_node_recursive(
107107
_metrics,
108108
)?;
109109
}
110-
} else {
110+
} else if matches!(kuchiki_node.data(), KuchikiNodeData::Document(_)) {
111111
// For document nodes, just process children directly
112112
for child in kuchiki_node.children() {
113113
convert_node_recursive(
@@ -120,6 +120,9 @@ fn convert_node_recursive(
120120
_metrics,
121121
)?;
122122
}
123+
} else {
124+
// Blocked element: drop entire subtree to avoid leaking script/style contents
125+
tracing::debug!("🚫 Dropping blocked node and its children");
123126
}
124127

125128
Ok(())
@@ -386,4 +389,4 @@ mod tests {
386389
}
387390
}
388391
}
389-
}
392+
}

crates/parser/tests/test_servo_css_integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ mod tests {
105105

106106
// Verify that security analysis was performed
107107
if let Some(analysis) = &result.security_analysis {
108-
assert!(analysis.threat_level != css_security::ThreatLevel::Safe, "Should detect threats");
108+
assert!(analysis.threat_level != css_security::CssThreatLevel::Safe, "Should detect threats");
109109
assert!(analysis.violations_count > 0, "Should detect violations");
110110
}
111111

0 commit comments

Comments
 (0)