Skip to content

Commit 1dd87ce

Browse files
authored
fix: refuse to render non-string Markdown field values (via #5295)
1 parent f50bbec commit 1dd87ce

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/core/components/providers/markdown.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ DomPurify.addHook("beforeSanitizeElements", function (current, ) {
1919
const isPlainText = (str) => /^[A-Z\s0-9!?\.]+$/gi.test(str)
2020

2121
function Markdown({ source, className = "" }) {
22+
if (typeof source !== "string") {
23+
return null
24+
}
25+
2226
if(isPlainText(source)) {
2327
// If the source text is not Markdown,
2428
// let's save some time and just render it.

src/core/plugins/oas3/wrap-components/markdown.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ parser.block.ruler.enable(["table"])
1010
parser.set({ linkTarget: "_blank" })
1111

1212
export const Markdown = ({ source, className = "" }) => {
13+
if(typeof source !== "string") {
14+
return null
15+
}
16+
1317
if ( source ) {
1418
const html = parser.render(source)
1519
const sanitized = sanitizer(html)

0 commit comments

Comments
 (0)