5 changed files with 29 additions and 4 deletions

No files matched your search

+11
View File
@@ -1,5 +1,16 @@
# Changelog
## [1.0.0-beta.3] — 2026-11-26
### Fixed (VS Code / VSCodium)
- **Chat sidebar view loads cleanly in VSCodium.** Allowed space-separated
multi-origin `webview.cspSource` values (such as
`vscode-resource: https://*.vscode-cdn.net`) in `src/webview.js` instead of
throwing `unsafe value for the chat page` (which caused VSCodium to display
`An error occurred while loading view: llembas.chat`), while still blocking
CSP injection characters (`"`, `<`, `>`, `;`, newlines).
## [1.0.0-beta.2] — 2026-11-26
### Added (VS Code / VSCodium & Neovim)
+1 -1
View File
@@ -1 +1 @@
1.0.0-beta.2
1.0.0-beta.3
+1 -1
View File
@@ -735,7 +735,7 @@ function M._note(text)
note(text)
end
M.version = "1.0.0-beta.2"
M.version = "1.0.0-beta.3"
M._state = S -- for the tests
vim.api.nvim_create_autocmd("VimLeavePre", {
+7 -2
View File
@@ -7,8 +7,13 @@
* @param {{ cspSource: string, nonce: string, scriptUri: string, styleUri: string }} o
*/
function chatHtml(o) {
for (const v of [o.cspSource, o.nonce, o.scriptUri, o.styleUri]) {
if (typeof v !== 'string' || /["<>\s]/.test(v)) throw new Error('unsafe value for the chat page');
// VS Code / VSCodium's `webview.cspSource` may list multiple space-separated origins
// (e.g. "vscode-resource: https://*.vscode-cdn.net"); forbid quotes, angle brackets, semicolons and newlines.
if (typeof o.cspSource !== 'string' || !o.cspSource.trim() || /["<>;\r\n]/.test(o.cspSource)) {
throw new Error('unsafe cspSource for the chat page');
}
for (const v of [o.nonce, o.scriptUri, o.styleUri]) {
if (typeof v !== 'string' || !v || /["<>\s]/.test(v)) throw new Error('unsafe value for the chat page');
}
const csp = [
"default-src 'none'",
+9
View File
@@ -287,6 +287,15 @@ test('the page: a strict policy, one script with a nonce, nothing from elsewhere
assert.ok(!/\son[a-z]+=/.test(html), 'no inline handlers');
assert.ok(!/style=/.test(html), 'no inline styles');
assert.throws(() => chatHtml({ cspSource: 'x', nonce: 'a"b', scriptUri: 's', styleUri: 't' }));
// Real VSCodium passes space-separated CSP sources (e.g. "vscode-resource: https://*.vscode-cdn.net").
const multi = chatHtml({
cspSource: 'vscode-resource: https://file+.vscode-resource.vscode-cdn.net',
nonce: 'abc123',
scriptUri: 'https://file.example/media/chat.js',
styleUri: 'https://file.example/media/chat.css',
});
assert.ok(multi.includes('style-src vscode-resource: https://file+.vscode-resource.vscode-cdn.net;'));
assert.throws(() => chatHtml({ cspSource: "https://a.example; script-src 'unsafe-inline'", nonce: 'abc', scriptUri: 's', styleUri: 't' }));
});
test('the stylesheet takes every colour from the editor\'s theme', () => {