From 801d9e94c4b3b7e0c72dff41ff3406397a3f686f Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 3 Oct 2022 18:41:26 +0100 Subject: [PATCH] fix: sanitize schema types --- src/markdown/sanitize-schema.ts | 41 ++++++++++++++------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/src/markdown/sanitize-schema.ts b/src/markdown/sanitize-schema.ts index 1f1fd24f..1ffadbbb 100644 --- a/src/markdown/sanitize-schema.ts +++ b/src/markdown/sanitize-schema.ts @@ -1,9 +1,7 @@ import { defaultSchema } from "rehype-sanitize" import { allowedBlockquoteAttrs } from "./remark-callout" -// @ts-ignore -import type { Schema } from "hast-util-sanitize/lib" -const scheme: Schema = { +const scheme = { ...defaultSchema, tagNames: [ ...(defaultSchema.tagNames || []), @@ -14,31 +12,26 @@ const scheme: Schema = { ], attributes: { ...defaultSchema.attributes, - div: [ - ...(defaultSchema.attributes?.div || []), - ["className"], - ["style"], - ["id"], - ], - code: [["className"]], + div: [...(defaultSchema.attributes?.div || []), "className", "style", "id"], + code: ["className"], blockquote: allowedBlockquoteAttrs, video: [ - ["className"], - ["src"], - ["controls"], - ["loop"], - ["muted"], - ["autoplay"], - ["playsinline"], + "className", + "src", + "controls", + "loop", + "muted", + "autoplay", + "playsinline", ], iframe: [ - ["className"], - ["src"], - ["allowFullScreen"], - ["frameborder"], - ["width"], - ["height"], - ["allow"], + "className", + "src", + "allowFullScreen", + "frameborder", + "width", + "height", + "allow", ], }, }