Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
fix(charset): reject non-ASCII label whitespace
ldm08ee93a2241a2
diff --git a/moli-charset-parser/src/prescan.rs b/moli-charset-parser/src/prescan.rsindex f86f7114c..1e2c5b177 100644--- a/moli-charset-parser/src/prescan.rs+++ b/moli-charset-parser/src/prescan.rs@@ -186,7 +186,7 @@ fn html_token_attr_value(tag: &Tag, name: &str) -> Option<String> {}fn encoding_for_label(label: String) -> Option<&'static Encoding> {- Encoding::for_label(label.trim().as_bytes()).map(prescan_charset_override)+ Encoding::for_label(label.as_bytes()).map(prescan_charset_override)}/// Applies the two charset rewrites the prescan performs before returning adiff --git a/moli-charset-parser/src/tests.rs b/moli-charset-parser/src/tests.rsindex 9a6a70efb..7e1b1fb21 100644--- a/moli-charset-parser/src/tests.rs+++ b/moli-charset-parser/src/tests.rs@@ -14,6 +14,26 @@ fn finds_meta_charset() {);}+#[test]+fn encoding_labels_allow_only_ascii_whitespace() {+ for whitespace in [b'\t', b'\n', b'\x0C', b'\r', b' '] {+ let input = [+ br#"<meta charset=""#.as_slice(),+ &[whitespace],+ b"gbk",+ &[whitespace],+ br#"">"#.as_slice(),+ ]+ .concat();+ assert_eq!(sniff_html_meta_charset(&input), Some(encoding_rs::GBK));+ }++ assert_eq!(+ sniff_html_meta_charset(b"<meta charset=\"\xA0gbk\xA0\">"),+ None+ );+}+#[test]fn ignores_tag_name_prefixes_and_script_text() {assert_eq!(