Skip to content

Commit

Permalink
chore: remove html renderer sanitizes
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Nov 5, 2024
1 parent 57c0073 commit 67c1a46
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 31 deletions.
2 changes: 0 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"clsx": "^2.1.1",
"copy-to-clipboard": "^3.3.3",
"dayjs": "^1.11.13",
"dompurify": "^3.1.7",
"fuse.js": "^7.0.0",
"highlight.js": "^11.10.0",
"i18next": "^23.16.3",
Expand Down Expand Up @@ -55,7 +54,6 @@
"@bufbuild/protobuf": "^2.2.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/d3": "^7.4.3",
"@types/dompurify": "^3.0.5",
"@types/katex": "^0.16.7",
"@types/leaflet": "^1.9.14",
"@types/lodash-es": "^4.17.12",
Expand Down
23 changes: 0 additions & 23 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions web/src/components/MemoContent/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import clsx from "clsx";
import copy from "copy-to-clipboard";
import DOMPurify from "dompurify";
import hljs from "highlight.js";
import { CopyIcon } from "lucide-react";
import { useCallback, useMemo } from "react";
Expand All @@ -24,15 +23,11 @@ const CodeBlock: React.FC<Props> = ({ language, content }: Props) => {

// Users can set Markdown code blocks as `__html` to render HTML directly.
if (formatedLanguage === SpecialLanguage.HTML) {
const purify = DOMPurify(window);
return (
<div
className="w-full overflow-auto !my-2"
dangerouslySetInnerHTML={{
__html: purify.sanitize(content, {
ALLOWED_TAGS: ["iframe"],
ADD_ATTR: ["allow", "allowfullscreen", "frameborder", "scrolling"],
}),
__html: content,
}}
/>
);
Expand Down

0 comments on commit 67c1a46

Please sign in to comment.