diff --git a/bun.lock b/bun.lock index c4eae0506..03a18eb5a 100644 --- a/bun.lock +++ b/bun.lock @@ -32,6 +32,7 @@ "cron-parser": "^4.9.0", "dayjs": "^1.11.21", "deep-equal": "^2.2.3", + "dompurify": "^3.4.12", "echarts": "^5.6.0", "flatted": "^3.4.2", "ignore": "^6.0.2", @@ -59,6 +60,7 @@ "@testing-library/svelte": "^5.3.1", "@testing-library/user-event": "^14.6.1", "@types/deep-equal": "^1.0.4", + "@types/dompurify": "^3.2.0", "@types/remarkable": "^2.0.8", "@types/three": "^0.182.0", "@typescript-eslint/eslint-plugin": "^8.60.1", @@ -516,6 +518,8 @@ "@types/dlv": ["@types/dlv@1.1.5", "", {}, "sha512-JHOWNfiWepAhfwlSw17kiWrWrk6od2dEQgHltJw9AS0JPFoLZJBge5+Dnil2NfdjAvJ/+vGSX60/BRW20PpUXw=="], + "@types/dompurify": ["@types/dompurify@3.2.0", "", { "dependencies": { "dompurify": "*" } }, "sha512-Fgg31wv9QbLDA0SpTOXO3MaxySc4DKGLi8sna4/Utjo4r3ZRPdCt4UQee8BWr+Q5z21yifghREPJGYaEOEIACg=="], + "@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="], "@types/hast": ["@types/hast@3.0.4", "", { "dependencies": { "@types/unist": "*" } }, "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ=="], @@ -806,6 +810,8 @@ "dom-accessibility-api": ["dom-accessibility-api@0.5.16", "", {}, "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg=="], + "dompurify": ["dompurify@3.4.12", "", { "optionalDependencies": { "@types/trusted-types": "^2.0.7" } }, "sha512-zQvGet8Z2sWbQhCmfFz/T5QWH2oBmjnqK3qvOjaqaNLrLEF912WamU+ohnTp0TCep/MFVHpdJuCZEdFOdTnEFg=="], + "dotenv": ["dotenv@16.6.1", "", {}, "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow=="], "dunder-proto": ["dunder-proto@1.0.1", "", { "dependencies": { "call-bind-apply-helpers": "^1.0.1", "es-errors": "^1.3.0", "gopd": "^1.2.0" } }, "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A=="], diff --git a/package.json b/package.json index 85eaefc7e..1623eb16e 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "cron-parser": "^4.9.0", "dayjs": "^1.11.21", "deep-equal": "^2.2.3", + "dompurify": "^3.4.12", "echarts": "^5.6.0", "flatted": "^3.4.2", "ignore": "^6.0.2", @@ -73,6 +74,7 @@ "@testing-library/svelte": "^5.3.1", "@testing-library/user-event": "^14.6.1", "@types/deep-equal": "^1.0.4", + "@types/dompurify": "^3.2.0", "@types/remarkable": "^2.0.8", "@types/three": "^0.182.0", "@typescript-eslint/eslint-plugin": "^8.60.1", diff --git a/src/lib/components/modal.svelte b/src/lib/components/modal.svelte index 53646a83e..c3a8fd901 100644 --- a/src/lib/components/modal.svelte +++ b/src/lib/components/modal.svelte @@ -3,6 +3,7 @@ import { disableCommands } from '$lib/commandCenter'; import { Form } from '$lib/elements/forms'; import { Alert, Layout, Modal } from '@appwrite.io/pink-svelte'; + import DOMPurify from 'dompurify'; export let show = false; export let autoClose = true; @@ -51,7 +52,10 @@ on:dismiss={() => { error = null; }}> - {@html error} + {@html DOMPurify.sanitize(error, { + ALLOWED_TAGS: ['a'], + ALLOWED_ATTR: ['href', 'target', 'rel'] + })} {/if} @@ -78,7 +82,11 @@ } .alert-error :global(a) { - color: inherit; - text-decoration: underline; -} + color: inherit; + text-decoration: underline; + } + rt-error :global(a) { + color: inherit; + text-decoration: underline; + }