Skip to content

Commit

Permalink
Enable dompurify trusted types
Browse files Browse the repository at this point in the history
  • Loading branch information
Top-Cat committed Feb 1, 2025
1 parent e5f9647 commit c04767e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/core/components/providers/markdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function sanitizer(str, { useUnsafeMarkdown = false } = {}) {
FORBID_TAGS: ["style", "form"],
ALLOW_DATA_ATTR,
FORBID_ATTR,
RETURN_TRUSTED_TYPE: true
})
}
sanitizer.hasWarnedAboutDeprecation = false
10 changes: 5 additions & 5 deletions src/core/plugins/oas3/wrap-components/markdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ export const Markdown = ({ source, className = "", getConfigs = () => ({ useUnsa
if ( source ) {
const { useUnsafeMarkdown } = getConfigs()
const html = parser.render(source)
const sanitized = sanitizer(html, { useUnsafeMarkdown })

let trimmed

if(typeof sanitized === "string") {
trimmed = sanitized.trim()
}
if (typeof html === "string")
trimmed = html.trim()

const sanitized = sanitizer(trimmed, { useUnsafeMarkdown })

return (
<div
dangerouslySetInnerHTML={{
__html: trimmed
__html: sanitized
}}
className={cx(className, "renderedMarkdown")}
/>
Expand Down

0 comments on commit c04767e

Please sign in to comment.