@eclipse-docks/core 0.7.125 → 0.7.126

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-docks/core",
3
- "version": "0.7.125",
3
+ "version": "0.7.126",
4
4
  "description": "Eclipse Docks platform core: registries, services, parts, widgets, and API",
5
5
  "type": "module",
6
6
  "license": "EPL-2.0",
@@ -77,6 +77,7 @@
77
77
  "test:coverage": "vitest run --coverage"
78
78
  },
79
79
  "dependencies": {
80
+ "dompurify": "^3.2.7",
80
81
  "@awesome.me/webawesome": "^3.12.0",
81
82
  "@fortawesome/fontawesome-free": "^7.2.0",
82
83
  "@fortawesome/fontawesome-svg-core": "^7.2.0",
@@ -70,4 +70,5 @@ export {
70
70
  } from '../core/contribution-mapping';
71
71
  export { parseIconSpec, icon } from '../core/icon-utils';
72
72
  export type { ParsedIconSpec, IconOptions } from '../core/icon-utils';
73
+ export { sanitizeHtml, parseMarkdownHtml } from '../core/markdown-html';
73
74
 
@@ -1,9 +1,9 @@
1
1
  import { html, css } from "lit";
2
2
  import { customElement, state } from "lit/decorators.js";
3
3
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
4
- import { marked } from "marked";
5
4
  import { DocksPart } from "../parts/part";
6
5
  import { appLoaderService, type ReleaseEntry } from "../core/apploader";
6
+ import { parseMarkdownHtml } from "../core/markdown-html";
7
7
  import { createLogger } from "../core/logger";
8
8
 
9
9
  const logger = createLogger("ReleaseHistory");
@@ -112,9 +112,7 @@ export class DocksReleaseHistory extends DocksPart {
112
112
  const showUpdateHint = !isCurrent && isNewerThan(release.tag_name, this.appVersion);
113
113
  const atOldest = this.currentReleaseIndex === this.releases.length - 1;
114
114
  const atNewest = this.currentReleaseIndex === 0;
115
- const bodyHtml = release.body
116
- ? (marked.parse(release.body, { async: false }) as string)
117
- : "";
115
+ const bodyHtml = release.body ? parseMarkdownHtml(release.body) : "";
118
116
 
119
117
  return html`
120
118
  <div class="release-panel">
@@ -0,0 +1,11 @@
1
+ import DOMPurify from 'dompurify';
2
+ import { marked, type MarkedOptions } from 'marked';
3
+
4
+ export function sanitizeHtml(html: string): string {
5
+ return DOMPurify.sanitize(html);
6
+ }
7
+
8
+ export function parseMarkdownHtml(markdown: string, options?: MarkedOptions): string {
9
+ const html = marked.parse(markdown, { async: false, ...options }) as string;
10
+ return sanitizeHtml(html);
11
+ }
@@ -1,6 +1,6 @@
1
1
  import { html, TemplateResult, css } from "lit";
2
2
  import { unsafeHTML } from "lit/directives/unsafe-html.js";
3
- import { marked } from "marked";
3
+ import { parseMarkdownHtml } from "../core/markdown-html";
4
4
  import { DocksElement } from "./element";
5
5
 
6
6
  export abstract class DocksDialogContent extends DocksElement {
@@ -22,7 +22,7 @@ export abstract class DocksDialogContent extends DocksElement {
22
22
 
23
23
  protected renderMessage(message: string, markdown: boolean = false): TemplateResult {
24
24
  if (markdown) {
25
- const htmlContent = marked.parse(message, { async: false }) as string;
25
+ const htmlContent = parseMarkdownHtml(message);
26
26
  return html`<div class="dialog-message" style="white-space: normal;">${unsafeHTML(htmlContent)}</div>`;
27
27
  }
28
28
  return html`<div class="dialog-message" style="white-space: pre-line;">${message}</div>`;