Personal Telegram developer console for GitHub

test: prevent HTML interpolation of repository-controlled paths

davoodmehraban89 committed Oct 24, 2026 at 17:24 UTC 18f663c2962478f2016dfb309034277c18239e12
1 file changed +18
test/workspace-editor-dom-safety.test.js new
+18
@@ -0,0 +1,18 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import { renderWorkspaceEditorPage } from '../src/workspace-editor.js';
4 +
5 +test('editor creates file options using textContent, never HTML interpolation', () => {
6 + const page = renderWorkspaceEditorPage();
7 + assert.match(page, /document\.createElement\('option'\)/);
8 + assert.match(page, /option\.textContent = file\.path/);
9 + assert.match(page, /option\.value = file\.path/);
10 + assert.match(page, /files\.replaceChildren\(\)/);
11 + assert.doesNotMatch(page, /files\.innerHTML\s*=/);
12 +});
13 +
14 +test('editor page does not embed arbitrary file names in executable markup', () => {
15 + const page = renderWorkspaceEditorPage();
16 + assert.match(page, /for \(const file of \(body\.workspace\.files/);
17 + assert.doesNotMatch(page, /<option value=['\"][^\n]*file\.path/);
18 +});