From fcb4d1546abba54102ccfd92382f44ea1d0148b9 Mon Sep 17 00:00:00 2001 From: DragonWork <97512+DragonWork@users.noreply.github.com> Date: Sat, 12 Sep 2026 15:18:19 +0000 Subject: [PATCH] Preserve non-NBSP UTF-8 bytes during HTML serialization --- html5ever/src/serialize/mod.rs | 1 + rcdom/tests/html-serializer.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/html5ever/src/serialize/mod.rs b/html5ever/src/serialize/mod.rs index cce3eae8..7cab15b9 100644 --- a/html5ever/src/serialize/mod.rs +++ b/html5ever/src/serialize/mod.rs @@ -139,6 +139,7 @@ impl HtmlSerializer { }, _ => { // 0xC2 not followed by 0xA0 (not NBSP), so keep looking. + self.writer.write_all(&bytes[next_special..search_start])?; continue; }, }; diff --git a/rcdom/tests/html-serializer.rs b/rcdom/tests/html-serializer.rs index e3775072..176a417d 100644 --- a/rcdom/tests/html-serializer.rs +++ b/rcdom/tests/html-serializer.rs @@ -146,6 +146,10 @@ test!( r#""# ); test!(attr_escape_amp, r#""#); +test!( + attr_literal_non_nbsp_c2, + r#"

"# +); test!( attr_escape_amp_2, r#""#, @@ -168,6 +172,7 @@ test!( ); test!(text_literal, r#"

"'"

"#); +test!(text_literal_non_nbsp_c2, "

©® «&»

"); test!(text_escape_amp, r#"

&

"#); test!(text_escape_amp_2, r#"

&

"#, r#"

&

"#); test!(text_escape_nbsp, "

x\u{a0}y

", r#"

x y

"#);