Unverified Commit 7670c953 authored by boojack's avatar boojack Committed by GitHub

chore: fix XSS in renderer (#880)

parent 65e9fdea
import { marked } from "..";
import Link from "./Link";
import PlainText from "./PlainText";
export const BOLD_REG = /\*\*(.+?)\*\*/;
......@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
return rawStr;
}
const parsedContent = marked(matchResult[1], [], [Link]);
const parsedContent = marked(matchResult[1], [], [Link, PlainText]);
return `<strong>${parsedContent}</strong>`;
};
......
import { marked } from "..";
import Link from "./Link";
import PlainText from "./PlainText";
export const BOLD_EMPHASIS_REG = /\*\*\*(.+?)\*\*\*/;
......@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
return rawStr;
}
const parsedContent = marked(matchResult[1], [], [Link]);
const parsedContent = marked(matchResult[1], [], [Link, PlainText]);
return `<strong><em>${parsedContent}</em></strong>`;
};
......
import { marked } from "..";
import Link from "./Link";
import PlainText from "./PlainText";
export const EMPHASIS_REG = /\*(.+?)\*/;
......@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
return rawStr;
}
const parsedContent = marked(matchResult[1], [], [Link]);
const parsedContent = marked(matchResult[1], [], [Link, PlainText]);
return `<em>${parsedContent}</em>`;
};
......
......@@ -4,6 +4,7 @@ import Bold from "./Bold";
import { marked } from "..";
import InlineCode from "./InlineCode";
import BoldEmphasis from "./BoldEmphasis";
import PlainText from "./PlainText";
export const LINK_REG = /\[(.*?)\]\((.+?)\)+/;
......@@ -17,7 +18,7 @@ const renderer = (rawStr: string): string => {
if (!matchResult) {
return rawStr;
}
const parsedContent = marked(matchResult[1], [], [InlineCode, BoldEmphasis, Emphasis, Bold]);
const parsedContent = marked(matchResult[1], [], [InlineCode, BoldEmphasis, Emphasis, Bold, PlainText]);
return `<a class='link' target='_blank' rel='noreferrer' href='${escape(matchResult[2])}'>${parsedContent}</a>`;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment