Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/core/components/providers/markdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import { linkify } from "remarkable/linkify"
import DomPurify from "dompurify"
import cx from "classnames"

if (DomPurify.addHook) {
DomPurify.addHook("beforeSanitizeElements", function (current, ) {
// Attach safe `rel` values to all elements that contain an `href`,
// i.e. all anchors that are links.
// We _could_ just look for elements that have a non-self target,
// but applying it more broadly shouldn't hurt anything, and is safer.
const scopedDomPurify = typeof window !== "undefined" ? DomPurify(window) : DomPurify

if (scopedDomPurify.addHook) {
scopedDomPurify.addHook("beforeSanitizeElements", function (current) {
if (current.href) {
current.setAttribute("rel", "noopener noreferrer")
}
Expand Down Expand Up @@ -62,7 +60,7 @@ export function sanitizer(str, { useUnsafeMarkdown = false } = {}) {
sanitizer.hasWarnedAboutDeprecation = true
}

return DomPurify.sanitize(str, {
return scopedDomPurify.sanitize(str, {
ADD_ATTR: ["target"],
FORBID_TAGS: ["style", "form"],
ALLOW_DATA_ATTR,
Expand Down
4 changes: 4 additions & 0 deletions src/core/config/type-cast/mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const mappings = {
typeCaster: booleanTypeCaster,
defaultValue: defaultOptions.persistAuthorization,
},
queryConfigEnabled: {
typeCaster: booleanTypeCaster,
defaultValue: defaultOptions.queryConfigEnabled,
},
plugins: {
typeCaster: arrayTypeCaster,
defaultValue: defaultOptions.plugins,
Expand Down