Repository navigation
Don't blank the map when the code holds a letter that grows when lower-cased (like "İ") - #118
Merged
haydenschmitty merged 1 commit intoNov 15, 2026
Conversation
…when lower-cased scriptBlocks() found the script tags in html.toLowerCase() and then sliced html at those positions. A few letters get longer when lower-cased: the Turkish "İ" (U+0130) becomes "i" plus a combining dot (U+0307). One of them anywhere before the scripts moved every later script body by a character, so the hashes in the Content-Security-Policy were wrong, the browser blocked those scripts and the map drew nothing. Only A-Z are lower-cased now, as the HTML parser does for tag names, so the copy always lines up with the page. Adds a test, and a changelog line under Unreleased. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Merged and released in 0.10.0. Thank you for the clear write-up! Update with |
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.
What this changes
The map opened blank on a project whose code holds a Turkish "İ" in a comment. The browser console showed "Executing inline script violates the following Content Security Policy directive" for every inline script after the map's data.
Cause:
scriptBlocks()inassets/page-safety.mjsfinds the script tags inhtml.toLowerCase(), then sliceshtmlat those positions. A few letters get longer when lower-cased:"İ".toLowerCase()(U+0130) is two characters, "i" plus a combining dot (U+0307). So one such letter anywhere before the scripts (in a comment the scan picked up, a file name or a description) moves every later script body by one character. The hashes in the policy no longer match what the browser hashes, and it blocks those scripts.Fix: lower-case only A to Z, the way the HTML parser matches tag names, so the copy is always the same length as the page:
Every name the function looks for (
script,style,title,textarea,<!--) is ASCII, so nothing else changes. No issue was filed first; this PR describes the bug.How I tested it
tests/hostile-content.test.mjs: an "İ" in the title, inside a script and in the body, with an upper-case<SCRIPT>.scriptBlocks()returns the exact bodies, and the policy allows exactly their hashes. The test fails onmainand passes with the change.npm test: 286 pass, 0 fail, 1 skipped (the Windows-onlyclaude.exetest), on macOS with Node 24.claude plugin validate .passes.Checklist
npm testpassesclaude plugin validate .passesCHANGELOG.mdupdated, if people will notice the change🤖 Generated with Claude Code