max / goingson
1 file changed,
+5 insertions,
-3 deletions
| @@ -317,10 +317,12 @@ function validateForm(form) { | |||
| 317 | 317 | function formatEmailBody(body) { | |
| 318 | 318 | if (!body) return ''; | |
| 319 | 319 | ||
| 320 | - | // Check if body contains HTML that needs stripping | |
| 320 | + | // Strip HTML for reader mode if the body contains any tag. (Detect any | |
| 321 | + | // `<tag …>` rather than a hand-maintained denylist that missed e.g. <img>/<a>; | |
| 322 | + | // escapeHtml below is the actual XSS defense and runs unconditionally either | |
| 323 | + | // way, so this only affects readability — ultra-fuzz Run #28.) | |
| 321 | 324 | let text = body; | |
| 322 | - | if (body.includes('<html') || body.includes('<body') || body.includes('<div') || | |
| 323 | - | body.includes('<table') || body.includes('<p>') || body.includes('<br')) { | |
| 325 | + | if (/<[a-z][a-z0-9]*\b[^>]*>/i.test(body)) { | |
| 324 | 326 | text = stripHtmlForReaderMode(body); | |
| 325 | 327 | } | |
| 326 | 328 |