Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- **One unusual letter no longer blanks the map:** to list the page's own scripts in its Content-Security-Policy, the build reads a lower-cased copy of the page, and a few letters get longer when lower-cased (the Turkish "İ" becomes two characters). One of them anywhere before the scripts, in a comment the scan picked up, a file name or a description, moved every later script by one character in that copy, so their fingerprints were wrong, the browser blocked them and the map drew nothing. Only A to Z are lower-cased now, the way the browser reads tag names, so the copy always lines up with the page.

## 0.7.3 (2026-11-10)

- **A long description no longer covers the map in a short window:** when the map opened in a window that isn’t very tall (a laptop screen, or the map inside a frame), the heading’s description could run over the top row of boxes, because only part of the heading was kept clear when the map was fitted. The whole heading is now kept clear (up to just under half the window), and in a window under 760 pixels tall a long description folds to three lines with a More / Less toggle, as it already did on phones.
Expand Down
4 changes: 3 additions & 1 deletion skills/floorplan/assets/page-safety.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ const isEnd = (c) => c === undefined || /[\t\n\f\r />]/.test(c);
* Returns [{ start, open, end, body, attrs }]: `body` is the text between the tags.
*/
export function scriptBlocks(html) {
const lower = html.toLowerCase();
// Only A-Z, as the browser matches tag names: a full toLowerCase() makes some letters longer (the Turkish "İ"
// becomes "i" plus a combining dot), which would shift every index below against `html`.
const lower = html.replace(/[A-Z]/g, (c) => c.toLowerCase());
const out = [];
let i = 0;
while (i < lower.length) {
Expand Down
10 changes: 10 additions & 0 deletions tests/hostile-content.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ describe('Content-Security-Policy', () => {
const page = withPolicy('<!doctype html><html><head>\n<meta charset="utf-8">\n<script>1</script></head></html>', 'export');
assert.equal(withPolicy(page, 'export'), page, 'adding the policy again replaces it');
});

test('a letter that grows when lower-cased (the Turkish "İ") can\'t shift the scripts or their hashes', async () => {
const { scriptBlocks, withPolicy } = await pageSafety();
const I = String.fromCharCode(0x130); // its toLowerCase() is two characters: "i" and a combining dot
const bodies = [`var a = "${I}${I}";`, 'var b = 2;', 'var c = 3;'];
const html = `<!doctype html><html><head>\n<meta charset="utf-8">\n<title>${I}</title><script>${bodies[0]}</script>\n<SCRIPT>${bodies[1]}</SCRIPT></head><body>${I}<script>${bodies[2]}</script></body></html>`;
assert.deepEqual(scriptBlocks(html).map((x) => x.body), bodies);
const want = new Set(bodies.map((b) => `'sha256-${crypto.createHash('sha256').update(b).digest('base64')}'`));
assert.deepEqual(new Set(policyOf(withPolicy(html, 'export')).directives['script-src']), want, 'the policy allows exactly the page\'s scripts');
});
});

// ---------- 4. patterns that would crash the build ----------
Expand Down