From 600ff95315ada4078b1d9df35bab85363665de3f Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 16 Oct 2026 14:38:23 +0530 Subject: [PATCH] Fix rich() eating raw < in math, title-case chapter titles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sanitizer root cause: a '<' followed by space/digit (e.g. '\(a < 0\)') was parsed as a tag, failed allowlist, and got DELETED along with its content — unbalancing KaTeX delimiters and killing all math after it on the page. Now only '<' followed by letter, /, ! or ? starts a tag; everything else becomes <. 4 regression tests added. CSS: .zp-chk-wrap and .zp-subtopic-row labels no longer inherit the generic uppercase rule, so chapter names render in DB title case ('Quadratic Equations', not 'QUADRATIC EQUATIONS'). --- src/views.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++++- static/style.css | 6 ++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/views.rs b/src/views.rs index 2ff1726..3d86784 100644 --- a/src/views.rs +++ b/src/views.rs @@ -26,6 +26,14 @@ pub fn rich(s: &str) -> String { "br", "p", "sup", "sub", "b", "strong", "i", "em", "u", "ol", "ul", "li", "table", "tbody", "thead", "tr", "th", "td", "span", ]; + // A `<` only starts a tag when followed by a letter, `/`, `!` or `?` + // (i.e. `

`, `

`, `