From a82f370bb7ada5b97474dd6b41f4843d24633712 Mon Sep 17 00:00:00 2001 From: Pierre Le Fevre Date: Sat, 28 Mar 2026 08:11:37 +0100 Subject: [PATCH] Review fix: use break instead of ? in parse_meta_tag attribute loop When parse_attribute returns None (e.g., malformed HTML with bare '=' or '/' not followed by '>'), the previously collected charset info should be preserved rather than discarded. Using break instead of ? ensures already-parsed charset/http-equiv attributes are still evaluated at the end of the function. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/encoding/src/sniff.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/encoding/src/sniff.rs b/crates/encoding/src/sniff.rs index 1672b48..7ac2aff 100644 --- a/crates/encoding/src/sniff.rs +++ b/crates/encoding/src/sniff.rs @@ -188,7 +188,9 @@ fn parse_meta_tag(bytes: &[u8], start: usize) -> Option<(Encoding, usize)> { break; } - let (attr_name, attr_value, new_pos) = parse_attribute(bytes, pos)?; + let Some((attr_name, attr_value, new_pos)) = parse_attribute(bytes, pos) else { + break; + }; pos = new_pos; if ascii_ci_eq_str(&attr_name, "http-equiv") { -- 2.51.2