From 4b143c31c398c60cd11b7dd53d47acfb6214b385 Mon Sep 17 00:00:00 2001 From: Costa Halicea Date: Wed, 17 Jun 2026 15:28:11 +0200 Subject: [PATCH] Escape HTML by default (text + attribute values) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close the XSS gap: HtmlTextNode and HtmlAttribute values are now HTML-escaped (& < > " ') via a vectorized HtmlEscape (SearchValues scan + verbatim fast path — zero cost when there's nothing to escape, no allocation). - Raw(string)/RawHtml is the opt-out (verbatim). - "; + const string note = "a\"b&c<"; + var live = Render(Views.Escaped(user, note)); + var opt = Render(Views__Optimized.Escaped(user, note)); + Assert.Equal(live, opt); // plan escapes identically to live + Assert.Contains("<script>", live); // and it really is escaped + Assert.DoesNotContain("