From 9a481f066e1427d53a06cf7aeec525a745abf03f Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 20 Nov 2023 11:06:01 +0100 Subject: fix: remove rehype-sanitize to avoid broken layouts The `rehype-sanitize` plugin was removing some tags inside the post contents coming from WordPress so the layout was broken. This plugin is useful to avoid DOM clobbering but I trust rehype-slug and myself so it is safe to remove it. --- package.json | 1 - src/utils/helpers/rehype.ts | 2 -- yarn.lock | 17 ----------------- 3 files changed, 20 deletions(-) diff --git a/package.json b/package.json index c595c9f..3d98086 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "react-dom": "^18.2.0", "react-intl": "^6.5.5", "rehype-parse": "^9.0.0", - "rehype-sanitize": "^6.0.0", "rehype-slug": "^6.0.0", "rehype-stringify": "^10.0.0", "schema-dts": "^1.1.2", diff --git a/src/utils/helpers/rehype.ts b/src/utils/helpers/rehype.ts index 2716c62..fc51da1 100644 --- a/src/utils/helpers/rehype.ts +++ b/src/utils/helpers/rehype.ts @@ -9,14 +9,12 @@ export const updateContentTree = async (content: string): Promise => { const { unified } = await import('unified'); const rehypeParse = (await import('rehype-parse')).default; - const rehypeSanitize = (await import('rehype-sanitize')).default; const rehypeSlug = (await import('rehype-slug')).default; const rehypeStringify = (await import('rehype-stringify')).default; return unified() .use(rehypeParse, { fragment: true }) .use(rehypeSlug) - .use(() => rehypeSanitize({ clobberPrefix: 'h-' })) .use(rehypeStringify) .processSync(content) .toString(); diff --git a/yarn.lock b/yarn.lock index fc3e029..ca5cba9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8892,15 +8892,6 @@ hast-util-raw@^9.0.0: web-namespaces "^2.0.0" zwitch "^2.0.0" -hast-util-sanitize@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/hast-util-sanitize/-/hast-util-sanitize-5.0.1.tgz#8e90068cd68e651c569960b77a1b25076579b4cf" - integrity sha512-IGrgWLuip4O2nq5CugXy4GI2V8kx4sFVy5Hd4vF7AR2gxS0N9s7nEAVUyeMtZKZvzrxVsHt73XdTsno1tClIkQ== - dependencies: - "@types/hast" "^3.0.0" - "@ungap/structured-clone" "^1.2.0" - unist-util-position "^5.0.0" - hast-util-to-estree@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/hast-util-to-estree/-/hast-util-to-estree-3.1.0.tgz#f2afe5e869ddf0cf690c75f9fc699f3180b51b19" @@ -12914,14 +12905,6 @@ rehype-parse@^9.0.0: hast-util-from-html "^2.0.0" unified "^11.0.0" -rehype-sanitize@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/rehype-sanitize/-/rehype-sanitize-6.0.0.tgz#16e95f4a67a69cbf0f79e113c8e0df48203db73c" - integrity sha512-CsnhKNsyI8Tub6L4sm5ZFsme4puGfc6pYylvXo1AeqaGbjOYyzNv3qZPwvs0oMJ39eryyeOdmxwUIo94IpEhqg== - dependencies: - "@types/hast" "^3.0.0" - hast-util-sanitize "^5.0.0" - rehype-slug@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/rehype-slug/-/rehype-slug-6.0.0.tgz#1d21cf7fc8a83ef874d873c15e6adaee6344eaf1" -- cgit v1.2.3