ulysses/static/js
SurprisedDuck b70ae56ffa
Sanitize preserved markdown HTML
`mdToHtml` deliberately stashes literal <details> blocks and <a> tags from
the source text *before* the global HTML-escape pass and restores them
verbatim into the string callers assign to `innerHTML` (e.g. chatRenderer's
`b.innerHTML = ...processWithThinking(text)`). Nothing scrubbed those
fragments, so message/agent content containing
`<details><img src=x onerror=...></details>` or
`<a href="javascript:..." onmouseover=...>` executed arbitrary script in
the authenticated page.

Route both stashed fragments through `sanitizeAllowedHtml()`, which parses
them in an inert <template> (no resource loads, no script execution),
removes script-capable elements, and strips event-handler attributes plus
javascript:/vbscript:/data: URL schemes. Hardening details:

- Compare tag names case-insensitively and drop the SVG/MathML foreign-
  content roots. An SVG-namespaced <script> has the lower-case tagName
  'script', so an HTML-only upper-case check would miss it — a real bypass.
- Sanitize to a fixpoint (re-parse + re-clean until stable) to blunt
  mutation-XSS, where re-serializing/re-parsing reshapes the tree.

Benign anchors and <details> blocks are preserved unchanged.

Verified under jsdom against the obvious vectors plus mutation-XSS probes
(svg/math-namespaced <script>, foreignObject, ns-confusion, comment
breakout, template smuggling): no script/iframe element, event handler, or
javascript:/data: URL survives, and benign markup is kept.

Co-authored-by: Claude <noreply@anthropic.com>
2026-06-02 05:58:38 +09:00
..
calendar Odysseus v1.0 2026-05-31 23:58:26 +09:00
compare Fix duplicate compare modal on repeated clicks (#491) 2026-06-01 22:24:27 +09:00
editor feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
emailLibrary Escape email fold summary metadata 2026-06-02 05:50:53 +09:00
research feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
admin.js feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
assistant.js feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
calendar.js Avoid caching failed calendar fetch ranges 2026-06-01 15:17:57 +09:00
censor.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
chat.js Fix chat stream recovery and PDF library indexing (#468) 2026-06-01 22:33:35 +09:00
chatRenderer.js Close stale setup and line-ending gaps 2026-06-01 10:43:35 +09:00
chatStream.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
codeRunner.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
colorPicker.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
cookbook-diagnosis.js Clarify Cookbook diffusion dependencies 2026-06-01 11:45:26 +09:00
cookbook-hwfit.js fix: require GGUF sources for llama downloads (#368) 2026-06-01 22:47:47 +09:00
cookbook.js fix: report serve dependency readiness (#412) 2026-06-01 22:39:36 +09:00
cookbookDownload.js fix: require GGUF sources for llama downloads (#368) 2026-06-01 22:47:47 +09:00
cookbookRunning.js Restore dependency refresh after install AND persist safe download mode on retries. (#499) 2026-06-01 22:28:06 +09:00
cookbookServe.js Add macOS Apple Silicon Cookbook support 2026-06-01 14:59:19 +09:00
document.js Polish email tasks and window controls 2026-06-01 20:56:46 +09:00
documentLibrary.js Fix library space toggles 2026-06-01 14:50:06 +09:00
dragSort.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
emailInbox.js Polish email reply and task controls 2026-06-01 23:02:25 +09:00
emailLibrary.js Polish email reply and task controls 2026-06-01 23:02:25 +09:00
emojiPicker.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
fileHandler.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
gallery.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
galleryEditor.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
group.js Await character templates before populating group dropdowns 2026-06-01 15:18:32 +09:00
init.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
keyboard-shortcuts.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
langIcons.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
markdown.js Sanitize preserved markdown HTML 2026-06-02 05:58:38 +09:00
memory.js feat: allow memory import without session (#493) 2026-06-01 22:32:17 +09:00
modalManager.js Improve space toggles and email warmup 2026-06-01 14:35:38 +09:00
modalSnap.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
modelPicker.js feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
models.js feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
modelSort.js feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
MODULE_SUMMARY.md Odysseus v1.0 2026-05-31 23:58:26 +09:00
notes.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
presets.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
providers.js feat(ai): add OpenRouter and Ollama Cloud providers (#231) 2026-06-01 14:26:10 +09:00
rag.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
researchSynapse.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
search-chat.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
search.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
section-management.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
sessions.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
settings.js Polish email tasks and window controls 2026-06-01 20:56:46 +09:00
sidebar-layout.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
signature.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
skills.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
slashCommands.js Validate slash command time minutes 2026-06-02 05:50:19 +09:00
spinner.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
storage.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
tasks.js Polish email reply and task controls 2026-06-01 23:02:25 +09:00
theme.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
tileManager.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
tourAutoplay.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
tourHints.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
tts-ai.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
ui.js Polish email tasks and window controls 2026-06-01 20:56:46 +09:00
voiceRecorder.js Odysseus v1.0 2026-05-31 23:58:26 +09:00
windowDrag.js Odysseus v1.0 2026-05-31 23:58:26 +09:00