domma-cms 1.44.0 → 1.45.0

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.
@@ -2097,6 +2097,29 @@ export function scrubCodeRegions(markdown, preserveIndented = false) {
2097
2097
  return {scrubbed, restore};
2098
2098
  }
2099
2099
 
2100
+ /**
2101
+ * marked.parse for a shortcode's BODY while later shortcodes inside it have not
2102
+ * run yet. Marked reads their tags as text: quotes become " and a URL turns
2103
+ * into a link, so [hero size="md"] inside [reveal] (or [tabs], [accordion], ...)
2104
+ * reached the hero as size="md" - class hero-"md" - and an
2105
+ * [embed url="https://..."] arrived as an <a> tag and was refused. Every tag
2106
+ * that carries attributes is held out of marked and put back exactly as written;
2107
+ * code spans and fences are left to marked, so an example tag there still shows
2108
+ * as code. Bare tags ([/hero], [center]) are left alone - marked does not change them.
2109
+ */
2110
+ let shieldCallId = 0;
2111
+ const ATTR_TAG = /\[\/?[a-z][\w-]*\s[^\]\n]*=[^\]\n]*\](?![(\[:])/gi;
2112
+ function markedBody(md) {
2113
+ const text = String(md ?? '');
2114
+ if (!text.includes('=')) return marked.parse(text);
2115
+ const id = ++shieldCallId;
2116
+ const held = [];
2117
+ const {scrubbed, restore} = scrubCodeRegions(text);
2118
+ const shielded = restore(scrubbed.replace(ATTR_TAG, (tag) => { held.push(tag); return `DMSCT${id}x${held.length - 1}x`; }));
2119
+ if (!held.length) return marked.parse(text);
2120
+ return marked.parse(shielded).replace(new RegExp(`DMSCT${id}x(\\d+)x`, 'g'), (_, i) => held[Number(i)]);
2121
+ }
2122
+
2100
2123
  /**
2101
2124
  * Run all plugin-registered shortcode handlers against the markdown string.
2102
2125
  * Self-closing ([name attrs /]) and wrapping ([name attrs]...[/name]) forms are both supported.
@@ -2229,7 +2252,7 @@ function processEffectsBlocks(markdown) {
2229
2252
  // Native hover fireworks need a hit target; the base decoration ignores pointer events.
2230
2253
  const style = hover ? ' style="pointer-events:auto;--dm-fw-size:var(--dm-fw-particle-size)"' : '';
2231
2254
  const particles = hover ? '' : '<div class="firework-launch"></div><div class="firework-particles"></div>';
2232
- const innerHtml = body === null ? '' : marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2255
+ const innerHtml = body === null ? '' : markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2233
2256
  return `<div class="${classes.join(' ')}"${style}>${particles}${innerHtml}</div>\n`;
2234
2257
  });
2235
2258
 
@@ -2253,7 +2276,7 @@ function processEffectsBlocks(markdown) {
2253
2276
  if (!hasActions) {
2254
2277
  // Restore code placeholders before the nested parse (tabs-handler
2255
2278
  // pattern) so code spans/fences render as <code>, not raw backticks.
2256
- const innerHtml = marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2279
+ const innerHtml = markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2257
2280
  return `<div class="dm-fx-scribe"${dataAttrs}${styleAttrs}>${innerHtml}</div>\n`;
2258
2281
  }
2259
2282
  const actions = [];
@@ -2290,10 +2313,10 @@ function processEffectsBlocks(markdown) {
2290
2313
  apply(name, (attrStr, body) => {
2291
2314
  if (body === null) return '';
2292
2315
  const attrs = parseShortcodeAttrs(attrStr);
2293
- const dataAttrs = Object.entries(attrs).map(([k, v]) => ` data-fx-${k}="${v}"`).join('');
2316
+ const dataAttrs = Object.entries(attrs).map(([k, v]) => ` data-fx-${k}="${escapeAttr(String(v))}"`).join('');
2294
2317
  // Restore code placeholders before the nested parse (tabs-handler
2295
2318
  // pattern) so code spans/fences render as <code>, not raw backticks.
2296
- const innerHtml = marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2319
+ const innerHtml = markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2297
2320
  return `<div class="dm-fx-${name}"${dataAttrs}>${innerHtml}</div>\n`;
2298
2321
  });
2299
2322
  }
@@ -2310,7 +2333,7 @@ function processEffectsBlocks(markdown) {
2310
2333
  }
2311
2334
  // Restore code placeholders before the nested parse (tabs-handler
2312
2335
  // pattern) so code spans/fences render as <code>, not raw backticks.
2313
- const innerHtml = marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2336
+ const innerHtml = markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2314
2337
  return `<div class="dm-fx-ticker-tape" data-fx-mode="container"${dataAttrs}>${innerHtml}</div>\n`;
2315
2338
  });
2316
2339
 
@@ -2328,7 +2351,7 @@ function processEffectsBlocks(markdown) {
2328
2351
  }
2329
2352
  // Restore code placeholders before the nested parse (tabs-handler
2330
2353
  // pattern) so code spans/fences render as <code>, not raw backticks.
2331
- const innerHtml = marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2354
+ const innerHtml = markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
2332
2355
  return `<div class="dm-fx-${name}" data-fx-mode="container"${dataAttrs}>${innerHtml}</div>\n`;
2333
2356
  });
2334
2357
  }
@@ -2341,7 +2364,7 @@ function processEffectsBlocks(markdown) {
2341
2364
  if (attrs.duration) classes.push(`animate-duration-${attrs.duration}`);
2342
2365
  if (attrs.delay) classes.push(`animate-delay-${attrs.delay}`);
2343
2366
  if (attrs.repeat) classes.push(`animate-${attrs.repeat}`);
2344
- return `<div class="${classes.join(' ')}">${marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))))}</div>\n`;
2367
+ return `<div class="${classes.join(' ')}">${markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))))}</div>\n`;
2345
2368
  });
2346
2369
 
2347
2370
  apply('ambient', (attrStr, body) => {
@@ -2351,7 +2374,7 @@ function processEffectsBlocks(markdown) {
2351
2374
  if (attrs.type) classes.push(`bg-ambient-${attrs.type}`);
2352
2375
  if (attrs.speed) classes.push(`bg-ambient-${attrs.speed}`);
2353
2376
  if (attrs.intensity) classes.push(`bg-ambient-${attrs.intensity}`);
2354
- return `<div class="${classes.join(' ')}">${marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))))}</div>\n`;
2377
+ return `<div class="${classes.join(' ')}">${markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))))}</div>\n`;
2355
2378
  });
2356
2379
 
2357
2380
  return restore(result);
@@ -2423,7 +2446,7 @@ function processGridBlocks(markdown) {
2423
2446
  // processCardBlocks, which creates its own empty store and fails to
2424
2447
  // decode them, producing the literal string "undefined" in place of
2425
2448
  // whatever was in <pre>, ``` fences, or `inline code`.
2426
- return `<div${cls}${id}${injected.effectDataAttrs}>${marked.parse(processCardBlocks(processInlineShortcodes(restore(body.trim()))))}</div>`;
2449
+ return `<div${cls}${id}${injected.effectDataAttrs}>${markedBody(processCardBlocks(processInlineShortcodes(restore(body.trim()))))}</div>`;
2427
2450
  }
2428
2451
  );
2429
2452
 
@@ -2819,7 +2842,7 @@ const LAYOUT_RENDERERS = {};
2819
2842
 
2820
2843
  LAYOUT_RENDERERS['basic'] = (attrs, body) => {
2821
2844
  const im = cardImageParts(attrs, body, marked);
2822
- const bodyHtml = marked.parse(im.body.trim());
2845
+ const bodyHtml = markedBody(im.body.trim());
2823
2846
  return `${cardRoot(attrs)}${im.media}${im.wrapBody(bodyHtml)}${cardFooterAttr(attrs)}</div>\n`;
2824
2847
  };
2825
2848
 
@@ -2827,7 +2850,7 @@ LAYOUT_RENDERERS['header-body'] = (attrs, body) => {
2827
2850
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2828
2851
  const hdr = title ? `<div class="card-header"><div class="card-title">${escapeAttr(title)}</div></div>` : '';
2829
2852
  const im = cardImageParts(attrs, body, marked);
2830
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(im.body.trim())));
2853
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(im.body.trim())));
2831
2854
  return `${cardRoot(attrs)}${im.media}${hdr}${im.wrapBody(bodyHtml)}${cardFooterAttr(attrs)}</div>\n`;
2832
2855
  };
2833
2856
 
@@ -2836,7 +2859,7 @@ LAYOUT_RENDERERS['header-body-footer'] = (attrs, body) => {
2836
2859
  const footer = typeof attrs.footer === 'string' ? attrs.footer.trim() : '';
2837
2860
  const hdr = title ? `<div class="card-header"><div class="card-title">${escapeAttr(title)}</div></div>` : '';
2838
2861
  const im = cardImageParts(attrs, body, marked);
2839
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(im.body.trim())));
2862
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(im.body.trim())));
2840
2863
  const ftr = footer ? `<div class="card-footer">${escapeAttr(footer)}</div>` : '';
2841
2864
  return `${cardRoot(attrs)}${im.media}${hdr}${im.wrapBody(bodyHtml)}${ftr}</div>\n`;
2842
2865
  };
@@ -2844,7 +2867,7 @@ LAYOUT_RENDERERS['header-body-footer'] = (attrs, body) => {
2844
2867
  LAYOUT_RENDERERS['no-header-footer'] = (attrs, body) => {
2845
2868
  const footer = typeof attrs.footer === 'string' ? attrs.footer.trim() : '';
2846
2869
  const im = cardImageParts(attrs, body, marked);
2847
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(im.body.trim())));
2870
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(im.body.trim())));
2848
2871
  const ftr = footer ? `<div class="card-footer">${escapeAttr(footer)}</div>` : '';
2849
2872
  return `${cardRoot(attrs)}${im.media}${im.wrapBody(bodyHtml)}${ftr}</div>\n`;
2850
2873
  };
@@ -2855,7 +2878,7 @@ LAYOUT_RENDERERS['icon-top'] = (attrs, body) => {
2855
2878
  const icon = typeof attrs.icon === 'string' ? attrs.icon.trim() : '';
2856
2879
  const iconHtml = icon ? `<span data-icon="${escapeAttr(icon)}" class="card-icon"></span>` : '';
2857
2880
  const subHtml = subtitle ? `<div class="card-subtitle">${escapeAttr(subtitle)}</div>` : '';
2858
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2881
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(body.trim())));
2859
2882
  const ih = cardIconHeaderAttrs(attrs);
2860
2883
  return `${cardRoot(attrs)}
2861
2884
  <div class="card-header card-header-icon-stacked${ih.cls}"${ih.style}>
@@ -2870,7 +2893,7 @@ LAYOUT_RENDERERS['icon-inline'] = (attrs, body) => {
2870
2893
  const icon = typeof attrs.icon === 'string' ? attrs.icon.trim() : '';
2871
2894
  const iconHtml = icon ? `<span data-icon="${escapeAttr(icon)}"></span>` : '';
2872
2895
  const subHtml = subtitle ? `<div class="card-subtitle">${escapeAttr(subtitle)}</div>` : '';
2873
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2896
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(body.trim())));
2874
2897
  const ih = cardIconHeaderAttrs(attrs);
2875
2898
  return `${cardRoot(attrs)}
2876
2899
  <div class="card-header card-header-icon-inline${ih.cls}"${ih.style}>
@@ -2882,13 +2905,13 @@ LAYOUT_RENDERERS['icon-inline'] = (attrs, body) => {
2882
2905
  LAYOUT_RENDERERS['image-top'] = (attrs, body) => {
2883
2906
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2884
2907
  const hdr = title ? `<div class="card-header"><div class="card-title">${escapeAttr(title)}</div></div>` : '';
2885
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2908
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(body.trim())));
2886
2909
  return `${cardRoot(attrs)}<div class="card-img-top"${imgStyle(attrs)}></div>${hdr}<div class="card-body">${bodyHtml}</div>${cardFooterAttr(attrs)}</div>\n`;
2887
2910
  };
2888
2911
 
2889
2912
  LAYOUT_RENDERERS['image-overlay'] = (attrs, body) => {
2890
2913
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2891
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2914
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(body.trim())));
2892
2915
  return `${cardRoot(attrs)}
2893
2916
  <div class="card-img-overlay"${imgStyle(attrs)}>
2894
2917
  <div class="card-overlay-text"><div class="card-title">${escapeAttr(title)}</div></div>
@@ -2898,14 +2921,14 @@ LAYOUT_RENDERERS['image-overlay'] = (attrs, body) => {
2898
2921
 
2899
2922
  LAYOUT_RENDERERS['thumb-left'] = (attrs, body) => {
2900
2923
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2901
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2924
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(body.trim())));
2902
2925
  return `${cardRoot(attrs, ['card-layout-thumb-left'])}<div class="card-img-left"${imgStyle(attrs)}></div>
2903
2926
  <div class="card-body">${title ? `<div class="card-title">${escapeAttr(title)}</div>` : ''}${bodyHtml}</div>${cardFooterAttr(attrs)}</div>\n`;
2904
2927
  };
2905
2928
 
2906
2929
  LAYOUT_RENDERERS['thumb-right'] = (attrs, body) => {
2907
2930
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2908
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2931
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(body.trim())));
2909
2932
  return `${cardRoot(attrs, ['card-layout-thumb-right'])}
2910
2933
  <div class="card-body">${title ? `<div class="card-title">${escapeAttr(title)}</div>` : ''}${bodyHtml}</div>
2911
2934
  <div class="card-img-right"${imgStyle(attrs)}></div></div>\n`;
@@ -2913,14 +2936,14 @@ LAYOUT_RENDERERS['thumb-right'] = (attrs, body) => {
2913
2936
 
2914
2937
  LAYOUT_RENDERERS['wide-left-image'] = (attrs, body) => {
2915
2938
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2916
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2939
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(body.trim())));
2917
2940
  return `${cardRoot(attrs, ['card-layout-horizontal'])}<div class="card-img-wide"${imgStyle(attrs)}></div>
2918
2941
  <div class="card-body">${title ? `<div class="card-title">${escapeAttr(title)}</div>` : ''}${bodyHtml}${cardFooterAttr(attrs)}</div></div>\n`;
2919
2942
  };
2920
2943
 
2921
2944
  LAYOUT_RENDERERS['full-bg'] = (attrs, body) => {
2922
2945
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2923
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2946
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(body.trim())));
2924
2947
  return `${cardRoot(attrs, ['dm-card-full-bg'])}<div class="card-img-top"${imgStyle(attrs)}></div>
2925
2948
  <div class="card-body">${title ? `<div class="card-title">${escapeAttr(title)}</div>` : ''}${bodyHtml}</div>${cardFooterAttr(attrs)}</div>\n`;
2926
2949
  };
@@ -2928,7 +2951,7 @@ LAYOUT_RENDERERS['full-bg'] = (attrs, body) => {
2928
2951
  LAYOUT_RENDERERS['split-half'] = (attrs, body) => {
2929
2952
  const title = typeof attrs.title === 'string' ? attrs.title.trim() : '';
2930
2953
  const gradient = typeof attrs.gradient === 'string' ? attrs.gradient.trim() : 'indigo';
2931
- const bodyHtml = marked.parse(processGridBlocks(processInlineShortcodes(body.trim())));
2954
+ const bodyHtml = markedBody(processGridBlocks(processInlineShortcodes(body.trim())));
2932
2955
  return `${cardRoot(attrs, ['card-layout-split'])}<div class="card-split-left card-gradient-${escapeAttr(gradient)}"${imgStyle(attrs)}></div>
2933
2956
  <div class="card-split-right"><div class="card-body">${title ? `<div class="card-title">${escapeAttr(title)}</div>` : ''}${bodyHtml}</div></div></div>\n`;
2934
2957
  };
@@ -2944,7 +2967,7 @@ LAYOUT_RENDERERS['avatar-profile'] = (attrs, body) => {
2944
2967
  const tags = typeof attrs.tags === 'string' ? attrs.tags.split(',').map(t => t.trim()).filter(Boolean) : [];
2945
2968
  const tagHtml = tags.length ? `<div class="card-tag-pills">${tags.map(t => `<span class="card-pill">${escapeAttr(t)}</span>`).join('')}</div>` : '';
2946
2969
  const iconHtml = icon ? `<span data-icon="${icon}"></span>` : '';
2947
- const bodyHtml = body.trim() ? `<div class="card-body">${marked.parse(body.trim())}</div>` : '';
2970
+ const bodyHtml = body.trim() ? `<div class="card-body">${markedBody(body.trim())}</div>` : '';
2948
2971
  return `${cardRoot(attrs)}<div class="card-avatar-wrap">
2949
2972
  <div class="card-avatar">${iconHtml}</div>
2950
2973
  ${title ? `<div class="card-title">${title}</div>` : ''}
@@ -2969,7 +2992,7 @@ LAYOUT_RENDERERS['stat-metric'] = (attrs, _body) => {
2969
2992
  LAYOUT_RENDERERS['quote-testimonial'] = (attrs, body) => {
2970
2993
  const author = escapeAttr(attrs.title || '');
2971
2994
  const role = escapeAttr(attrs.subtitle || '');
2972
- const bodyHtml = body.trim() ? marked.parse(body.trim()) : '';
2995
+ const bodyHtml = body.trim() ? markedBody(body.trim()) : '';
2973
2996
  return `${cardRoot(attrs)}<span class="card-quote-mark">\u201c</span>
2974
2997
  <div class="card-quote-text">${bodyHtml}</div>
2975
2998
  <div class="card-footer card-quote-attr">
@@ -2983,7 +3006,7 @@ LAYOUT_RENDERERS['callout'] = (attrs, body) => {
2983
3006
  const defaults = {info: '💡', warn: '⚠️', success: '✅', error: '❌'};
2984
3007
  const icon = escapeAttr(attrs.icon || defaults[type] || '💡');
2985
3008
  const title = escapeAttr(attrs.title || '');
2986
- const bodyHtml = marked.parse(body.trim());
3009
+ const bodyHtml = markedBody(body.trim());
2987
3010
  return `${cardRoot(attrs, ['card-callout', type])}<div class="card-callout-inner card-body">
2988
3011
  <div class="card-callout-icon"><span data-icon="${icon}"></span></div>
2989
3012
  <div>${title ? `<div class="card-title">${title}</div>` : ''}${bodyHtml}</div>
@@ -2993,7 +3016,7 @@ LAYOUT_RENDERERS['callout'] = (attrs, body) => {
2993
3016
  LAYOUT_RENDERERS['video-media'] = (attrs, body) => {
2994
3017
  const title = escapeAttr(attrs.title || '');
2995
3018
  const duration = escapeAttr(attrs.duration || '');
2996
- const bodyHtml = body.trim() ? marked.parse(body.trim()) : '';
3019
+ const bodyHtml = body.trim() ? markedBody(body.trim()) : '';
2997
3020
  const dur = duration ? `<div class="card-video-duration">${duration}</div>` : '';
2998
3021
  return `${cardRoot(attrs)}<div class="card-video-thumb"${imgStyle(attrs)}>
2999
3022
  <div class="card-play-btn">\u25B6</div>${dur}
@@ -3004,7 +3027,7 @@ LAYOUT_RENDERERS['video-media'] = (attrs, body) => {
3004
3027
  LAYOUT_RENDERERS['location-map'] = (attrs, body) => {
3005
3028
  const address = escapeAttr(attrs.address || '');
3006
3029
  const title = escapeAttr(attrs.title || '');
3007
- const bodyHtml = body.trim() ? marked.parse(body.trim()) : '';
3030
+ const bodyHtml = body.trim() ? markedBody(body.trim()) : '';
3008
3031
  return `${cardRoot(attrs)}<div class="card-map-placeholder">
3009
3032
  <div class="card-map-grid"></div><div class="card-map-pin">📍</div>
3010
3033
  </div>${title || address ? `<div class="card-body">${title ? `<div class="card-title">${title}</div>` : ''}${address ? `<div class="card-subtitle">${address}</div>` : ''}${bodyHtml}</div>` : ''}</div>\n`;
@@ -3014,7 +3037,7 @@ LAYOUT_RENDERERS['step-numbered'] = (attrs, body) => {
3014
3037
  const step = escapeAttr(String(attrs.step || '1'));
3015
3038
  const title = escapeAttr(attrs.title || '');
3016
3039
  const gradient = escapeAttr(attrs.gradient || 'indigo');
3017
- const bodyHtml = body.trim() ? marked.parse(body.trim()) : '';
3040
+ const bodyHtml = body.trim() ? markedBody(body.trim()) : '';
3018
3041
  return `${cardRoot(attrs)}<div class="card-step-bg card-gradient-${gradient}">
3019
3042
  <div class="card-step-badge">${step}</div>
3020
3043
  <div class="card-step-ghost">${step}</div>
@@ -3026,7 +3049,7 @@ LAYOUT_RENDERERS['corner-badge'] = (attrs, body) => {
3026
3049
  const badge = escapeAttr(attrs.badge || 'New');
3027
3050
  const title = escapeAttr(attrs.title || '');
3028
3051
  const icon = escapeAttr(attrs.icon || '');
3029
- const bodyHtml = body.trim() ? marked.parse(body.trim()) : '';
3052
+ const bodyHtml = body.trim() ? markedBody(body.trim()) : '';
3030
3053
  return `${cardRoot(attrs, ['card-corner-badge-wrap'])}<span class="card-corner-badge">${badge}</span>
3031
3054
  ${icon ? `<div style="display:flex;justify-content:center;padding:18px 16px 4px"><span data-icon="${icon}" style="font-size:2rem"></span></div>` : ''}
3032
3055
  <div class="card-body" style="text-align:center">${title ? `<div class="card-title">${title}</div>` : ''}${bodyHtml}</div>${cardFooterAttr(attrs)}</div>\n`;
@@ -3037,7 +3060,7 @@ LAYOUT_RENDERERS['badge-band'] = (attrs, body) => {
3037
3060
  const icon = escapeAttr(attrs.icon || '');
3038
3061
  const gradient = escapeAttr(attrs.gradient || 'indigo');
3039
3062
  const title = escapeAttr(attrs.title || '');
3040
- const bodyHtml = body.trim() ? marked.parse(body.trim()) : '';
3063
+ const bodyHtml = body.trim() ? markedBody(body.trim()) : '';
3041
3064
  return `${cardRoot(attrs)}<div class="card-badge-band card-gradient-${gradient}">
3042
3065
  <span class="card-badge-band-label">${badge}</span>
3043
3066
  ${icon ? `<span class="card-badge-band-icon" data-icon="${icon}"></span>` : ''}
@@ -3047,7 +3070,7 @@ LAYOUT_RENDERERS['badge-band'] = (attrs, body) => {
3047
3070
 
3048
3071
  LAYOUT_RENDERERS['glass-gradient-border'] = (attrs, body) => {
3049
3072
  const title = escapeAttr(attrs.title || '');
3050
- const bodyHtml = marked.parse(body.trim());
3073
+ const bodyHtml = markedBody(body.trim());
3051
3074
  return `<div class="card-glass-outer mb-4">
3052
3075
  <div class="card-glass-inner">
3053
3076
  ${title ? `<div class="card-title">${title}</div>` : ''}<div>${bodyHtml}</div>
@@ -3060,7 +3083,7 @@ LAYOUT_RENDERERS['rating-review'] = (attrs, body) => {
3060
3083
  const author = escapeAttr(attrs.title || '');
3061
3084
  const role = escapeAttr(attrs.subtitle || '');
3062
3085
  const verified = 'verified' in attrs;
3063
- const bodyHtml = body.trim() ? marked.parse(body.trim()) : '';
3086
+ const bodyHtml = body.trim() ? markedBody(body.trim()) : '';
3064
3087
  return `${cardRoot(attrs)}<span class="card-stars">${stars}</span>
3065
3088
  <div class="card-quote-text">${bodyHtml}</div>
3066
3089
  <div class="card-footer card-quote-attr">
@@ -3074,7 +3097,7 @@ LAYOUT_RENDERERS['tag-cloud'] = (attrs, body) => {
3074
3097
  const title = escapeAttr(attrs.title || '');
3075
3098
  const tagAttr = typeof attrs.tags === 'string' ? attrs.tags.split(',').map(t => t.trim()).filter(Boolean) : [];
3076
3099
  const tagHtml = tagAttr.map((t, i) => `<span class="card-tag" style="${tagColorStyle(i)}">${escapeAttr(t)}</span>`).join('');
3077
- const bodyHtml = body.trim() ? marked.parse(body.trim()) : '';
3100
+ const bodyHtml = body.trim() ? markedBody(body.trim()) : '';
3078
3101
  return `${cardRoot(attrs)}${title ? `<div class="card-header"><div class="card-title">${title}</div></div>` : ''}
3079
3102
  <div class="card-tag-cloud">${tagHtml}${bodyHtml}</div></div>\n`;
3080
3103
  };
@@ -3083,7 +3106,7 @@ LAYOUT_RENDERERS['timeline-entry'] = (attrs, body) => {
3083
3106
  const date = escapeAttr(attrs.subtitle || '');
3084
3107
  const title = escapeAttr(attrs.title || '');
3085
3108
  const tag = escapeAttr(attrs.badge || '');
3086
- const bodyHtml = body.trim() ? marked.parse(body.trim()) : '';
3109
+ const bodyHtml = body.trim() ? markedBody(body.trim()) : '';
3087
3110
  return `${cardRoot(attrs)}<div class="card-timeline-row">
3088
3111
  <div class="card-timeline-side"><div class="card-timeline-dot"></div><div class="card-timeline-line"></div></div>
3089
3112
  <div class="card-timeline-body">
@@ -3509,7 +3532,7 @@ function processTabsBlocks(markdown) {
3509
3532
  // so fenced code blocks render as <pre><code> rather than surviving as raw text
3510
3533
  // that would confuse subsequent scrubCodeRegions calls.
3511
3534
  const restoredBody = restore(tabBody.trim());
3512
- const bodyHtml = marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restoredBody))));
3535
+ const bodyHtml = markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restoredBody))));
3513
3536
  const icon = tabAttrs.icon ? tabAttrs.icon.trim() : '';
3514
3537
  items.push({title, icon, paneId, bodyHtml, first: tabIdx === 1});
3515
3538
  });
@@ -3564,7 +3587,7 @@ function processAccordionBlocks(markdown) {
3564
3587
  body.replace(/\[item([^\]]*)\]([\s\S]*?)\[\/item\]/gi, (__, itemAttr, itemBody) => {
3565
3588
  const itemAttrs = parseShortcodeAttrs(itemAttr);
3566
3589
  const title = itemAttrs.title || 'Item';
3567
- const bodyHtml = marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(itemBody.trim())))));
3590
+ const bodyHtml = markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(itemBody.trim())))));
3568
3591
  items += (
3569
3592
  `<div class="accordion-item">\n` +
3570
3593
  ` <h3 class="accordion-header"><button class="accordion-button" type="button">${escapeAttr(title)}` +
@@ -3637,7 +3660,7 @@ function processCarouselBlocks(markdown) {
3637
3660
  if (slideAttrs.image) {
3638
3661
  inner += `<img src="${escapeAttr(slideAttrs.image)}" alt="${escapeAttr(slideAttrs.title || '')}">\n`;
3639
3662
  }
3640
- const contentHtml = marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(slideBody.trim())))));
3663
+ const contentHtml = markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(slideBody.trim())))));
3641
3664
  if (slideAttrs.title || slideBody.trim()) {
3642
3665
  inner += `<div class="carousel-slide-content">`;
3643
3666
  if (slideAttrs.title) inner += `<h2 class="carousel-slide-title">${escapeAttr(slideAttrs.title)}</h2>`;
@@ -3740,7 +3763,7 @@ function processTimelineBlocks(markdown) {
3740
3763
  const status = ia.status ? ` data-status="${escapeAttr(ia.status)}"` : '';
3741
3764
  // data-event-icon, never data-icon - see renderCollectionTimeline: the icon scanner would empty the item.
3742
3765
  const icon = ia.icon ? ` data-event-icon="${escapeAttr(ia.icon)}"` : '';
3743
- const descHtml = marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(itemBody.trim())))));
3766
+ const descHtml = markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(itemBody.trim())))));
3744
3767
  return `<div class="dm-progression-item"${date}${status}${icon}><div class="dm-progression-item-title">${title}</div><div class="dm-progression-item-body">${descHtml}</div></div>`;
3745
3768
  }
3746
3769
  );
@@ -4960,7 +4983,7 @@ function processHeroBlocks(markdown) {
4960
4983
  inner += '<div class="hero-content">';
4961
4984
  if (title) inner += `<h1 class="hero-title hero-title-responsive">${escapeAttr(title)}</h1>`;
4962
4985
  if (tagline) inner += `<p class="hero-subtitle hero-subtitle-responsive">${escapeAttr(tagline)}</p>`;
4963
- if (processedBody) inner += `<div class="hero-body">${marked.parse(processedBody)}</div>`;
4986
+ if (processedBody) inner += `<div class="hero-body">${markedBody(processedBody)}</div>`;
4964
4987
  inner += '</div>';
4965
4988
 
4966
4989
  return `<div class="${classes.join(' ')}"${idAttr}${style}${injected.effectDataAttrs}>${inner}</div>\n`;
@@ -5026,7 +5049,7 @@ function processBannerBlocks(markdown) {
5026
5049
  const titleHtml = title
5027
5050
  ? `<strong class="dm-banner__title">${escapeAttr(title)}</strong>\n `
5028
5051
  : '';
5029
- const bodyHtml = marked.parse(body.trim());
5052
+ const bodyHtml = markedBody(body.trim());
5030
5053
  const dismissHtml = dismissible
5031
5054
  ? `\n <button type="button" class="dm-banner__dismiss" aria-label="Dismiss">×</button>`
5032
5055
  : '';
@@ -5055,7 +5078,7 @@ function processSlideoverBlocks(markdown) {
5055
5078
  const trigger = escapeAttr(attrs.trigger || 'Open');
5056
5079
  const size = escapeAttr(attrs.size || 'md');
5057
5080
  const position = escapeAttr(attrs.position || 'right');
5058
- const bodyHtml = marked.parse(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
5081
+ const bodyHtml = markedBody(processCardBlocks(processGridBlocks(processInlineShortcodes(restore(body.trim())))));
5059
5082
  return (
5060
5083
  `<button class="btn btn-link dm-so-trigger" data-so-target="${id}">${trigger}</button>\n` +
5061
5084
  `<div class="dm-so-content" id="${id}" style="display:none" ` +
@@ -51,6 +51,9 @@ export function licenceNotice(name, label, verdict, now = new Date()) {
51
51
  return {severity: 'warning', title: `${label} licence has expired`,
52
52
  body: `The ${label} licence ended on ${ends(e.expiresAt)}. It keeps working until ${fmtDate(graceEnd, {utc: true})}, then stops. Renew it before then.`};
53
53
  }
54
+ case 'not-covered':
55
+ return {severity: 'critical', title: `${label} is not running: this version needs a renewal`,
56
+ body: `This copy of ${label} is newer than your licence covers (${String(e.versions || '').replace(/^<=/, 'up to ')}), and its updates ended on ${ends(e.supportExpiresAt)}. Renew it in the Marketplace, or install the version your licence covers - its data is kept.`};
54
57
  case 'support-ended':
55
58
  return {severity: 'info', title: `${label}: support and updates have ended`,
56
59
  body: `Your ${label} licence is permanent and keeps working, but updates stopped on ${ends(e.supportExpiresAt)}.`};
@@ -183,7 +186,7 @@ export async function todoChanged(userId, todos, today) {
183
186
 
184
187
  export async function registerCoreSources() {
185
188
  const plugins = await import('./plugins.js');
186
- const {classifyEntitlement} = await import('./pluginEntitlement.js');
189
+ const {classifyEntitlement, coveredVerdict} = await import('./pluginEntitlement.js');
187
190
 
188
191
  registerNotificationSource({
189
192
  id: 'core:plugin-load', label: 'Plugin failed to start', severity: 'critical', every: 'boot',
@@ -227,7 +230,7 @@ export async function registerCoreSources() {
227
230
  if (m.closedSource !== true) continue;
228
231
  const key = `licence:${m.name}`;
229
232
  if (!states[m.name]?.enabled) { await resolve(key); continue; }
230
- const notice = licenceNotice(m.name, m.displayName || m.name, classifyEntitlement(m.name), now);
233
+ const notice = licenceNotice(m.name, m.displayName || m.name, coveredVerdict(classifyEntitlement(m.name), m.version), now);
231
234
  if (notice) await raise({...notice, dedupeKey: key, link: '#/plugins'});
232
235
  else await resolve(key);
233
236
  }
@@ -24,7 +24,7 @@
24
24
  import {createPublicKey, verify as cryptoVerify} from 'node:crypto';
25
25
  import fs from 'node:fs';
26
26
  import path from 'node:path';
27
- import {trustedKey} from './pluginInstaller.js';
27
+ import {compareVersions, trustedKey} from './pluginInstaller.js';
28
28
 
29
29
  /**
30
30
  * Canonical JSON: keys sorted at every depth, no whitespace, undefined dropped.
@@ -101,6 +101,7 @@ export function readEntitlement(slug) {
101
101
  * 'valid' load it
102
102
  * 'grace' load it, and say so - a rental just past its term
103
103
  * 'support-ended' load it - a perpetual licence whose updates have stopped
104
+ * (mayLoad() refuses a version newer than it covers: 'not-covered')
104
105
  * 'expired' do NOT load - a rental past its grace period
105
106
  * 'unlicensed' do NOT load - absent, malformed, or not signed by us
106
107
  *
@@ -153,6 +154,49 @@ export function classifyEntitlement(slug, entitlement = readEntitlement(slug), n
153
154
  return {state: 'valid', reason: '', entitlement};
154
155
  }
155
156
 
157
+ /**
158
+ * Does an entitlement's `versions` cover this version? The store mints a bought
159
+ * licence's entitlement as `<=X.Y.Z` - the version that download was - and '*'
160
+ * (or no field) for everything else. Comparisons are joined by spaces
161
+ * (`>=1.0.0 <=1.4.2`); a bare version means exactly that one. Anything else
162
+ * covers nothing: a ceiling read wrongly must never mean "no ceiling".
163
+ *
164
+ * @param {string|undefined} versions
165
+ * @param {string} version
166
+ * @returns {boolean}
167
+ */
168
+ export function versionsCover(versions, version) {
169
+ const spec = versions === undefined || versions === null ? '*' : String(versions).trim();
170
+ if (spec === '*' || spec === '') return true;
171
+ if (!/^\d+(?:\.\d+)*$/.test(String(version ?? ''))) return false;
172
+ return spec.split(/\s+/).every((part) => {
173
+ const m = /^(<=|>=|<|>|=)?(\d+(?:\.\d+)*)$/.exec(part);
174
+ if (!m) return false;
175
+ const c = compareVersions(version, m[2]);
176
+ switch (m[1]) {
177
+ case '<=': return c <= 0;
178
+ case '>=': return c >= 0;
179
+ case '<': return c < 0;
180
+ case '>': return c > 0;
181
+ default: return c === 0;
182
+ }
183
+ });
184
+ }
185
+
186
+ /**
187
+ * A perpetual licence whose support has ended covers only the versions it was
188
+ * given: dropping a newer copy in by hand (a .dcmsplugin from elsewhere) must
189
+ * not get round the renewal. While support runs, any version loads - an update
190
+ * from the store brings its own, wider entitlement with it.
191
+ */
192
+ export function coveredVerdict(verdict, version) {
193
+ if (verdict.state !== 'support-ended' || verdict.entitlement?.model !== 'perpetual') return verdict;
194
+ const versions = verdict.entitlement.versions;
195
+ if (versionsCover(versions, version)) return verdict;
196
+ return {...verdict, state: 'not-covered',
197
+ reason: `version ${version} is newer than this licence covers (${versions}) and its updates have ended`};
198
+ }
199
+
156
200
  /** The states that let a plugin load. */
157
201
  const LOADABLE = new Set(['valid', 'grace', 'support-ended']);
158
202
 
@@ -166,6 +210,6 @@ export function mayLoad(manifest) {
166
210
  if (manifest?.closedSource !== true) {
167
211
  return {allowed: true, state: 'not-required', reason: ''};
168
212
  }
169
- const {state, reason} = classifyEntitlement(manifest.name);
213
+ const {state, reason} = coveredVerdict(classifyEntitlement(manifest.name), manifest.version);
170
214
  return {allowed: LOADABLE.has(state), state, reason};
171
215
  }
@@ -132,6 +132,23 @@ export function trustedKeyIds(use) {
132
132
  * @param {string} b
133
133
  * @returns {number}
134
134
  */
135
+ /**
136
+ * The refusal for installing a version a bought licence no longer covers, or
137
+ * null. Checked before anything on disk changes, so the working copy stays.
138
+ * The entitlement is the incoming one, else the one the installation carries.
139
+ */
140
+ async function licenceShortfall(slug, manifest, entitlement) {
141
+ if (manifest?.closedSource !== true || !entitlement) return null;
142
+ const {classifyEntitlement, coveredVerdict} = await import('./pluginEntitlement.js');
143
+ const verdict = coveredVerdict(classifyEntitlement(slug, entitlement), manifest.version);
144
+ if (verdict.state !== 'not-covered') return null;
145
+ const ended = String(entitlement.supportExpiresAt || '').slice(0, 10);
146
+ const name = manifest.displayName || slug;
147
+ return Object.assign(new Error(`${name} ${manifest.version} came out after your updates ended${ended ? ` on ${ended}` : ''}. `
148
+ + `Your licence covers ${String(entitlement.versions).replace(/^<=/, 'up to ')}. Renew it in the Marketplace to install this version - the one you have keeps working.`),
149
+ {statusCode: 403, code: 'licence-versions', expose: true});
150
+ }
151
+
135
152
  export function compareVersions(a, b) {
136
153
  const parse = v => String(v ?? '').split('.').map(x => parseInt(x, 10) || 0);
137
154
  const av = parse(a);
@@ -411,6 +428,11 @@ export async function installPlugin(slug, { tarball, signature, publicKeyId, all
411
428
  await fs.rm(destDir, { recursive: true, force: true });
412
429
  throw cmsTooOldError(tooNew);
413
430
  }
431
+ const notCovered = await licenceShortfall(slug, manifest, entitlement);
432
+ if (notCovered) {
433
+ await fs.rm(destDir, { recursive: true, force: true });
434
+ throw notCovered;
435
+ }
414
436
 
415
437
  // Step 5 - Update config/plugins.json
416
438
  const cfg = await readPluginsConfig();
@@ -498,6 +520,15 @@ async function upgradePlugin(slug, {tarball, unsigned, entitlement, allowDowngra
498
520
  await fs.rm(incoming, {recursive: true, force: true});
499
521
  throw new Error(`Refusing to downgrade ${slug} from ${from} to ${to}.`);
500
522
  }
523
+ let heldEntitlement = entitlement;
524
+ if (!heldEntitlement) {
525
+ try { heldEntitlement = JSON.parse(await fs.readFile(path.join(destDir, '.entitlement.json'), 'utf8')); } catch { /* none */ }
526
+ }
527
+ const notCovered = await licenceShortfall(slug, next.manifest, heldEntitlement);
528
+ if (notCovered) {
529
+ await fs.rm(incoming, {recursive: true, force: true});
530
+ throw notCovered;
531
+ }
501
532
 
502
533
  // 3. Carry the site's data across.
503
534
  const dataDir = path.join(destDir, 'data');
@@ -14,7 +14,9 @@
14
14
  /** Parameter names redacted whatever their case. */
15
15
  // `code` and `state`: an OAuth2 callback (the mail sign-in) carries a live
16
16
  // authorisation code and its one-time ticket in the query string.
17
- const SENSITIVE = new Set(['token', 't', 'key', 'hostkey', 'invitekey', 'code', 'state']);
17
+ // `hub.verify_token`: a Meta (WhatsApp, Facebook) webhook subscription check sends
18
+ // the site's verify token in the query string (?hub.mode=subscribe&hub.verify_token=...).
19
+ const SENSITIVE = new Set(['token', 't', 'key', 'hostkey', 'invitekey', 'code', 'state', 'hub.verify_token']);
18
20
 
19
21
  /** Anything with secret or password in the name is redacted too. */
20
22
  const SENSITIVE_PATTERN = /secret|password|passwd/i;