Harden XSS URL checks, first-run docs, and CI - #1
Merged
Conversation
Reject camouflaged javascript: URLs (ZWSP, HTML entities, percent-encoding), fix Shift+G, and point the empty state at open-reader.command. Co-authored-by: andersyin <andersyin@users.noreply.github.com>
andersyin
marked this pull request as ready for review
August 13, 2026 04:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CI on
mainwas already green (Playwright 34/34). The claimed XSS hardening and first-run path were not:safeUrlonly stripped C0 whitespace, so ZWSP /:/%3Acould still producejavascript:-likehref/src.打开阅读器.command, a file that does not exist (open-reader.commanddoes).G(scroll to bottom) was dead code:e.key === 'g' || e.key === 'G'always won first.This PR hardens the sanitizer, fixes those first-run/docs bugs, and adds a cheap Node check so XSS regressions do not require Chrome. No new reader features.
Type of change
What changed
XSS / hardening
//.script-srcnonce,connect-src 'none') andReferrer-Policy: no-referrersofile://pages do not leak local paths when markdown has remote images.key_points/conclusions/action_itemscoerced withasListso a string/object field cannot throw.map.First-run
bash open-reader.command notes.mdand leads with drag-and-drop.python3, portableopen/xdg-open, warn when there is no bundle yet, do not abort after a successful bundle if the desktop opener fails.CI / tests
permissions: contents: read,bash -n+ ShellCheck onopen-reader.command.test/sanitize.mjs(no browser) covers camouflage vectors, fixture render, CSP/zero-CDN, empty-state filename.xss-sample.mdfixture and edit-injected camouflage (37 assertions).Docs
http(s)images inside markdown still fetch. README JSON sidecar example is valid JSON. File tree lists CONTRIBUTING / CI /sanitize.mjs.Testing
Please confirm GitHub Actions is green on this PR before merging. After merge, a smoke test is: double-click
md-reader.html, drag in a.mdfile, and on macOSbash open-reader.command notes.md.Checklist
Do not merge until you have reviewed — this is the next repo after video-analysis-gemini.