Unverified Commit 64e5c343 authored by boojack's avatar boojack Committed by GitHub

chore: fix XSS in renderer (#875)

chore: fix xss in renderer
parent 9169b3f2
......@@ -47,7 +47,7 @@ export const marked = (markdownStr: string, blockParsers = blockElementParserLis
const matchedLength = matchedStr.length;
const prefixStr = markdownStr.slice(0, matchedIndex);
const suffixStr = markdownStr.slice(matchedIndex + matchedLength);
return prefixStr + matchedInlineParser.renderer(matchedStr) + marked(suffixStr, [], inlineParsers);
return marked(prefixStr, [], inlineParsers) + matchedInlineParser.renderer(matchedStr) + marked(suffixStr, [], inlineParsers);
}
}
......
import { escape } from "lodash";
import { marked } from "..";
import Link from "./Link";
......@@ -15,7 +14,7 @@ const renderer = (rawStr: string): string => {
return rawStr;
}
const parsedContent = marked(escape(matchResult[1]), [], [Link]);
const parsedContent = marked(matchResult[1], [], [Link]);
return `<strong>${parsedContent}</strong>`;
};
......
import { escape } from "lodash";
import { marked } from "..";
import Link from "./Link";
......@@ -15,7 +14,7 @@ const renderer = (rawStr: string): string => {
return rawStr;
}
const parsedContent = marked(escape(matchResult[1]), [], [Link]);
const parsedContent = marked(matchResult[1], [], [Link]);
return `<strong><em>${parsedContent}</em></strong>`;
};
......
import { escape } from "lodash";
import { marked } from "..";
import Link from "./Link";
......@@ -15,7 +14,7 @@ const renderer = (rawStr: string): string => {
return rawStr;
}
const parsedContent = marked(escape(matchResult[1]), [], [Link]);
const parsedContent = marked(matchResult[1], [], [Link]);
return `<em>${parsedContent}</em>`;
};
......
......@@ -17,7 +17,7 @@ const renderer = (rawStr: string): string => {
if (!matchResult) {
return rawStr;
}
const parsedContent = marked(escape(matchResult[1]), [], [InlineCode, BoldEmphasis, Emphasis, Bold]);
const parsedContent = marked(matchResult[1], [], [InlineCode, BoldEmphasis, Emphasis, Bold]);
return `<a class='link' target='_blank' rel='noreferrer' href='${escape(matchResult[2])}'>${parsedContent}</a>`;
};
......
import { marked } from "..";
import { escape } from "lodash";
export const STRIKETHROUGH_REG = /~~(.+?)~~/;
......@@ -13,8 +13,7 @@ const renderer = (rawStr: string): string => {
return rawStr;
}
const parsedContent = marked(matchResult[1], [], []);
return `<del>${parsedContent}</del>`;
return `<del>${escape(matchResult[1])}</del>`;
};
export default {
......
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