domma-cms 1.47.1 → 1.47.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/plugins/blog/CHANGELOG.md +3 -0
- package/plugins/blog/admin/views/post-editor.js +5 -2
- package/plugins/blog/plugin.json +1 -1
- package/plugins/blog/tests/preview-sandbox.test.js +33 -0
- package/plugins/free-tier.lock.json +6 -5
- package/server/services/markdown.js +26 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.47.2] - 2026-11-08
|
|
4
|
+
|
|
5
|
+
- **Security: a shortcode parameter can no longer close the attribute it is written into.** `[card class=…]` (and `[box]`, which builds on it) was pushed into `class="…"` unescaped, and `[animate]`, `[ambient]`, `[grid]`/`[col]` and the hero's blobs built class names from parameters as written (`animate-${type}`, `gap-${gap}`, `grid-cols-${cols}`, `col-span-${span}`). A quote in one added attributes of its own - a `data-config` that site.js acts on, for one. The class is now escaped and class-building parameters keep to letters, digits, `_` and `-` (`classToken()` in markdown.js).
|
|
6
|
+
|
|
3
7
|
## [1.47.1] - 2026-11-08
|
|
4
8
|
|
|
5
9
|
- Chat: a request naming an unknown chat launcher (`/api/chat/config`, `/state`, `/send` and the rest) is answered once. The 404 was sent and then Fastify tried to answer again, which logged "Reply was already sent" and "Cannot write headers after they are sent" each time. The visitor already got the 404 - only the log changes.
|
package/package.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.10.3] - 2026-11-08
|
|
4
|
+
- **Security: the post preview runs no scripts.** The editor's preview iframe is sandboxed (`allow-same-origin`, no `allow-scripts`). It showed the rendered post same-origin with the admin and ran the site's scripts, so markup in a post someone else wrote - another author, or an API token - could run as the admin previewing it. The preview lifts the page cloak itself, so it still shows; interactive bits (tabs, carousels) are static in the preview.
|
|
5
|
+
|
|
3
6
|
## [1.10.2] - 2026-11-08
|
|
4
7
|
- A post created as published gets a published date (only Publish stamped one).
|
|
5
8
|
|
|
@@ -41,7 +41,7 @@ const PREVIEW_PANEL = `
|
|
|
41
41
|
<button type="button" class="btn btn-sm btn-primary" data-on-click="use" data-bind-disabled="!changed.value">Use this layout</button>
|
|
42
42
|
</div>
|
|
43
43
|
<div class="blog-preview-stage" data-bind-class="'is-' + width.value">
|
|
44
|
-
<iframe title="Post preview"></iframe>
|
|
44
|
+
<iframe sandbox="allow-same-origin" title="Post preview"></iframe>
|
|
45
45
|
</div>
|
|
46
46
|
</div>`;
|
|
47
47
|
|
|
@@ -148,7 +148,10 @@ function mountLayoutCard(card, {current, collect, catalogue, kit, add}) {
|
|
|
148
148
|
if (mine !== seq || !alive) return;
|
|
149
149
|
if (res?.error) throw new Error(res.error);
|
|
150
150
|
// The page's own addresses (/dist/…, /plugins/…) resolve against the site.
|
|
151
|
-
|
|
151
|
+
// Sandboxed with no scripts (the iframe's sandbox="allow-same-origin"): a post is written by
|
|
152
|
+
// other people too - authors, API tokens - and must never run as the admin previewing it.
|
|
153
|
+
// With no scripts Domma never lifts the body's cloak, so the preview lifts it itself.
|
|
154
|
+
frame.srcdoc = String(res.html).replace(/<head>/i, `<head><base href="${location.origin}/"><style>body.dm-cloaked{opacity:1 !important;transition:none !important}</style>`);
|
|
152
155
|
state.value = '';
|
|
153
156
|
} catch (err) {
|
|
154
157
|
if (mine === seq && alive) state.value = err?.message ?? 'Preview failed.';
|
package/plugins/blog/plugin.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The post preview is sandboxed with NO scripts: a post's body is written by
|
|
3
|
+
* other people (authors, API tokens), and the preview frame is same-origin with
|
|
4
|
+
* the admin - running the site's scripts there ran the post's markup as them.
|
|
5
|
+
* Blog Pro's two previews (its post editor, Appearance) hold to the same.
|
|
6
|
+
*/
|
|
7
|
+
import {test} from 'node:test';
|
|
8
|
+
import assert from 'node:assert/strict';
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
|
|
13
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
|
|
14
|
+
const FRAMES = [
|
|
15
|
+
'blog/admin/views/post-editor.js',
|
|
16
|
+
'blog-pro/admin/views/post-editor.js',
|
|
17
|
+
'blog-pro/admin/templates/appearance.html'
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
test('every Blog preview iframe is sandboxed without allow-scripts', () => {
|
|
21
|
+
for (const rel of FRAMES) {
|
|
22
|
+
const file = path.join(ROOT, rel);
|
|
23
|
+
if (!fs.existsSync(file)) continue; // Blog Pro is not on every checkout
|
|
24
|
+
const src = fs.readFileSync(file, 'utf8');
|
|
25
|
+
const frames = [...src.matchAll(/<iframe\b[^>]*>/g)].map(m => m[0]);
|
|
26
|
+
assert.ok(frames.length, `${rel} has its preview iframe`);
|
|
27
|
+
for (const f of frames) {
|
|
28
|
+
const sandbox = f.match(/sandbox="([^"]*)"/);
|
|
29
|
+
assert.ok(sandbox, `${rel}: ${f} is sandboxed`);
|
|
30
|
+
assert.doesNotMatch(sandbox[1], /allow-scripts/, `${rel}: no scripts in the preview`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"note": "Written by `make sync-free-tier` in dcms-marketplace. Do not edit these plugins here - edit them there and sync.",
|
|
3
|
-
"source": "dcms-marketplace@
|
|
3
|
+
"source": "dcms-marketplace@f7fadbe",
|
|
4
4
|
"plugins": {
|
|
5
5
|
"blog": {
|
|
6
|
-
"version": "1.10.
|
|
6
|
+
"version": "1.10.3",
|
|
7
7
|
"files": {
|
|
8
|
-
"CHANGELOG.md": "
|
|
8
|
+
"CHANGELOG.md": "af44457efba1401fa781d40c691f301946bdc1567ab9aa00e2479d3fc3817359",
|
|
9
9
|
"CLAUDE.md": "357072eb15b3c2b04b25a18ed44b3d569e1bbdf927118d5b472a9b952c3778d0",
|
|
10
10
|
"admin/css/index.css": "8d6dfd2bfadf0bbe8efbd52ef9b397ca9d36ca699c80e260aec11f677c77a248",
|
|
11
11
|
"admin/lib/drafts.js": "60446f6bf93b790f07041fbb95dac30b12cd0ebc3caa71d15f2a7dc16c661b0d",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"admin/views/categories.js": "92946bba9740e5f3ce6770bf283d5db5f061353cf7afa10ecf1dac38ead7d837",
|
|
20
20
|
"admin/views/comments.js": "ead4477f75c751cc1940ce2e5d272f6498c4940a34f69b3e896c47c7c9c4e263",
|
|
21
21
|
"admin/views/kit.js": "a7d705de235bd7f125e5ff0607134863c1e67112f3b5876ed97dbbdded202dbc",
|
|
22
|
-
"admin/views/post-editor.js": "
|
|
22
|
+
"admin/views/post-editor.js": "8bc81317decd579be5f110a3f21a44ecb9ee66c5f6b110f7900f4462da3a1959",
|
|
23
23
|
"admin/views/settings-cog.js": "307efc93835863dd8511f8fb17a224cf45a77532c90b854a86d2cd1d4e5f9f18",
|
|
24
24
|
"admin/views/settings.js": "256729c7fc2c7cc30541b19afd2efb335a8ac2cc8bdf15202a360c9b7c07c1e4",
|
|
25
25
|
"blocks/blog-card-compact.css": "eb8e8ae9a6461c362bc021ea0396c6b4481047b6b36a50eeb59e47375e49be75",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"lib/render.js": "0e97c6a950bc962c8d8ea4b2f21d06cb73fbcdc738d8942d6935d01309a29b1d",
|
|
55
55
|
"lib/samples.js": "e8cdb77ce22e43937707f6854d3a5cb722437dc584e22ac7b24480bef686cf85",
|
|
56
56
|
"plugin.js": "689bd734b0aa9c2b9a780a6c2274a91492a55471a2397376111c84a28e7c35df",
|
|
57
|
-
"plugin.json": "
|
|
57
|
+
"plugin.json": "d58c3da0d9fbb0784251caff12125cd26630a8427c46def195b5015f5bc0307e",
|
|
58
58
|
"plugin.public.js": "0718b1610cebbdcca43012c9c4b67774c1baca2d4ccdcec4ddbd991458951cd8",
|
|
59
59
|
"public/blog.css": "fd733e6b624190da1e70dc1b6613e2376efd7f7570a28fab311d81006d03d960",
|
|
60
60
|
"public/blog.js": "d01c72a9834dcc7c5241923371f2b164ac30d20ac9f1a5c5dc5b71fa3cb09f08",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"tests/layouts.test.js": "554cff8194bd650cfb5f2a83c1f51c25f427c07f7dbfdc2ad9ad69bb38fca6a0",
|
|
77
77
|
"tests/nav-link.test.js": "d36e33ad7483abca27ae6e2098ad2f75bafa18d91f3beba70372ebe6b9b88994",
|
|
78
78
|
"tests/notices.test.js": "2b02aa84e780dc4c82e6c503fc8fe17c64a63bee0709627866ef97c99cb4e131",
|
|
79
|
+
"tests/preview-sandbox.test.js": "fba7f5a640832a8b3f1fe8aa05b8dcb7349134f93dc6b385e33af2939bbb8919",
|
|
79
80
|
"tests/public.test.js": "cd4cc53da9709d400d082ef6df01b3f49e6fc419e4b020b588464306a5d907e9"
|
|
80
81
|
}
|
|
81
82
|
},
|
|
@@ -2360,10 +2360,10 @@ function processEffectsBlocks(markdown) {
|
|
|
2360
2360
|
if (body === null) return '';
|
|
2361
2361
|
const attrs = parseShortcodeAttrs(attrStr);
|
|
2362
2362
|
const classes = [];
|
|
2363
|
-
if (attrs.type) classes.push(`animate-${attrs.type}`);
|
|
2364
|
-
if (attrs.duration) classes.push(`animate-duration-${attrs.duration}`);
|
|
2365
|
-
if (attrs.delay) classes.push(`animate-delay-${attrs.delay}`);
|
|
2366
|
-
if (attrs.repeat) classes.push(`animate-${attrs.repeat}`);
|
|
2363
|
+
if (attrs.type) classes.push(`animate-${classToken(attrs.type)}`);
|
|
2364
|
+
if (attrs.duration) classes.push(`animate-duration-${classToken(attrs.duration)}`);
|
|
2365
|
+
if (attrs.delay) classes.push(`animate-delay-${classToken(attrs.delay)}`);
|
|
2366
|
+
if (attrs.repeat) classes.push(`animate-${classToken(attrs.repeat)}`);
|
|
2367
2367
|
return `<div class="${classes.join(' ')}">${markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))))}</div>\n`;
|
|
2368
2368
|
});
|
|
2369
2369
|
|
|
@@ -2371,9 +2371,9 @@ function processEffectsBlocks(markdown) {
|
|
|
2371
2371
|
if (body === null) return '';
|
|
2372
2372
|
const attrs = parseShortcodeAttrs(attrStr);
|
|
2373
2373
|
const classes = [];
|
|
2374
|
-
if (attrs.type) classes.push(`bg-ambient-${attrs.type}`);
|
|
2375
|
-
if (attrs.speed) classes.push(`bg-ambient-${attrs.speed}`);
|
|
2376
|
-
if (attrs.intensity) classes.push(`bg-ambient-${attrs.intensity}`);
|
|
2374
|
+
if (attrs.type) classes.push(`bg-ambient-${classToken(attrs.type)}`);
|
|
2375
|
+
if (attrs.speed) classes.push(`bg-ambient-${classToken(attrs.speed)}`);
|
|
2376
|
+
if (attrs.intensity) classes.push(`bg-ambient-${classToken(attrs.intensity)}`);
|
|
2377
2377
|
return `<div class="${classes.join(' ')}">${markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))))}</div>\n`;
|
|
2378
2378
|
});
|
|
2379
2379
|
|
|
@@ -2418,7 +2418,7 @@ function responsiveGridCols(cols) {
|
|
|
2418
2418
|
'5': ['grid-cols-1', 'grid-cols-md-2', 'grid-cols-lg-5'],
|
|
2419
2419
|
'6': ['grid-cols-1', 'grid-cols-md-3', 'grid-cols-lg-6'],
|
|
2420
2420
|
};
|
|
2421
|
-
return map[String(cols)] ?? [`grid-cols-${cols}`];
|
|
2421
|
+
return map[String(cols)] ?? [`grid-cols-${classToken(cols)}`];
|
|
2422
2422
|
}
|
|
2423
2423
|
|
|
2424
2424
|
function processGridBlocks(markdown) {
|
|
@@ -2431,7 +2431,7 @@ function processGridBlocks(markdown) {
|
|
|
2431
2431
|
const attrs = parseShortcodeAttrs(attrStr);
|
|
2432
2432
|
const COL_INJECTABLE = ['reveal', 'breathe', 'animate', 'ripple'];
|
|
2433
2433
|
const injected = extractInjectedEffects(attrs, COL_INJECTABLE);
|
|
2434
|
-
const baseCls = attrs.span ? `col-span-${attrs.span}` : 'col';
|
|
2434
|
+
const baseCls = attrs.span ? `col-span-${classToken(attrs.span)}` : 'col';
|
|
2435
2435
|
// Explicit alignment takes precedence over the shorthand flags.
|
|
2436
2436
|
const alignment = typeof attrs.align === 'string'
|
|
2437
2437
|
? attrs.align.trim().toLowerCase()
|
|
@@ -2456,7 +2456,7 @@ function processGridBlocks(markdown) {
|
|
|
2456
2456
|
(_, attrStr, inner) => {
|
|
2457
2457
|
const attrs = parseShortcodeAttrs(attrStr);
|
|
2458
2458
|
const classes = ['row'];
|
|
2459
|
-
if (attrs.gap) classes.push(`gap-${attrs.gap}`);
|
|
2459
|
+
if (attrs.gap) classes.push(`gap-${classToken(attrs.gap)}`);
|
|
2460
2460
|
if (attrs.class) classes.push(escapeAttr(attrs.class));
|
|
2461
2461
|
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
2462
2462
|
const reveal = attrs.reveal !== undefined ? ' data-reveal="true"' : '';
|
|
@@ -2482,12 +2482,12 @@ function processGridBlocks(markdown) {
|
|
|
2482
2482
|
const classes = ['grid'];
|
|
2483
2483
|
if (attrs.cols) {
|
|
2484
2484
|
if (attrs.responsive === 'false') {
|
|
2485
|
-
classes.push(`grid-cols-${attrs.cols}`);
|
|
2485
|
+
classes.push(`grid-cols-${classToken(attrs.cols)}`);
|
|
2486
2486
|
} else {
|
|
2487
2487
|
classes.push(...responsiveGridCols(attrs.cols));
|
|
2488
2488
|
}
|
|
2489
2489
|
}
|
|
2490
|
-
if (attrs.gap) classes.push(`gap-${attrs.gap}`);
|
|
2490
|
+
if (attrs.gap) classes.push(`gap-${classToken(attrs.gap)}`);
|
|
2491
2491
|
if (attrs.class) classes.push(escapeAttr(attrs.class));
|
|
2492
2492
|
if (attrs.fullwidth === 'true') classes.push('grid-breakout');
|
|
2493
2493
|
const id = attrs.id ? ` id="${escapeAttr(attrs.id)}"` : '';
|
|
@@ -2567,6 +2567,17 @@ export function collectAndRewriteComponents(source) {
|
|
|
2567
2567
|
return {output: restore(rewritten), used};
|
|
2568
2568
|
}
|
|
2569
2569
|
|
|
2570
|
+
/**
|
|
2571
|
+
* A shortcode parameter used as part of a class name (`animate-${type}`, `gap-${gap}`):
|
|
2572
|
+
* letters, digits, `_` and `-` only, so it can never close the attribute or add another.
|
|
2573
|
+
*
|
|
2574
|
+
* @param {unknown} value
|
|
2575
|
+
* @returns {string}
|
|
2576
|
+
*/
|
|
2577
|
+
export function classToken(value) {
|
|
2578
|
+
return String(value ?? '').replace(/[^\w-]/g, '');
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2570
2581
|
export function escapeAttr(str) {
|
|
2571
2582
|
return String(str)
|
|
2572
2583
|
.replace(/&/g, '&')
|
|
@@ -2646,7 +2657,8 @@ function cardVariantClasses(attrs) {
|
|
|
2646
2657
|
// A bare `hover` or any other value retains the explicit hover class.
|
|
2647
2658
|
if ('hover' in attrs) classes.push(isHoverOff(attrs.hover) ? 'card-no-hover' : 'card-hover');
|
|
2648
2659
|
if (attrs.collapsible === 'true') classes.push('card-collapsible');
|
|
2649
|
-
|
|
2660
|
+
// Escaped: the class is written into class="…" as it stands, and a quote in it closed the attribute.
|
|
2661
|
+
if (typeof attrs.class === 'string') classes.push(escapeAttr(attrs.class.trim()));
|
|
2650
2662
|
const font = typeof attrs.font === 'string' ? attrs.font.trim() : '';
|
|
2651
2663
|
if (['serif', 'mono'].includes(font)) classes.push(`card-font-${font}`);
|
|
2652
2664
|
const fontSize = typeof attrs['font-size'] === 'string' ? attrs['font-size'].trim() : '';
|
|
@@ -4937,7 +4949,7 @@ function processHeroBlocks(markdown) {
|
|
|
4937
4949
|
// Legacy ad-hoc 'blobs' flag - keep for backward compat. Different keyspace
|
|
4938
4950
|
// (bg-ambient-* CSS class), not folded into the generic helper.
|
|
4939
4951
|
const blobs = 'blobs' in attrs;
|
|
4940
|
-
const blobsType = attrs['blobs-type'] || 'float-blobs';
|
|
4952
|
+
const blobsType = classToken(attrs['blobs-type']) || 'float-blobs';
|
|
4941
4953
|
|
|
4942
4954
|
const classes = ['hero', 'hero-responsive'];
|
|
4943
4955
|
if (size) classes.push(`hero-${size}`);
|