mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
Scope DOMPurify config to call sites
Replace global setConfig with an exported sanitizeConfig passed inline. The global config leaked into mermaid's internal strict-mode sanitization, stripping valid SVG diagrams.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import type { BaseUrl, Node, NodeStats } from "@http-client";
|
||||
|
||||
import dompurify from "dompurify";
|
||||
import { markdown } from "@app/lib/markdown";
|
||||
import { markdown, sanitizeConfig } from "@app/lib/markdown";
|
||||
|
||||
import Command from "@app/components/Command.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
@@ -25,7 +25,8 @@
|
||||
function render(content: string): string {
|
||||
return dompurify.sanitize(
|
||||
markdown({ linkify: true, emojis: true }).parse(content) as string,
|
||||
);
|
||||
sanitizeConfig,
|
||||
) as string;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { BaseUrl, Repo, SeedingPolicy } from "@http-client";
|
||||
|
||||
import dompurify from "dompurify";
|
||||
import { markdown } from "@app/lib/markdown";
|
||||
import { markdown, sanitizeConfig } from "@app/lib/markdown";
|
||||
import { formatRepositoryId, twemoji } from "@app/lib/utils";
|
||||
|
||||
import Badge from "@app/components/Badge.svelte";
|
||||
@@ -19,7 +19,8 @@
|
||||
function render(content: string): string {
|
||||
return dompurify.sanitize(
|
||||
markdown({ linkify: true, emojis: true }).parseInline(content) as string,
|
||||
);
|
||||
sanitizeConfig,
|
||||
) as string;
|
||||
}
|
||||
|
||||
$: project = repo.payloads["xyz.radicle.project"];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import dompurify from "dompurify";
|
||||
import escape from "lodash/escape";
|
||||
import { sanitizeConfig } from "@app/lib/markdown";
|
||||
import { formatInlineTitle } from "@app/lib/utils";
|
||||
|
||||
export let content: string;
|
||||
@@ -23,5 +24,5 @@
|
||||
class:txt-heading-l={fontSize === "heading-l"}
|
||||
class:txt-body-l-medium={fontSize === "body-l-medium"}
|
||||
class:txt-body-m-regular={fontSize === "body-m-regular"}>
|
||||
{@html dompurify.sanitize(formatInlineTitle(escape(content)))}
|
||||
{@html dompurify.sanitize(formatInlineTitle(escape(content)), sanitizeConfig)}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user