Headline
CVE-2022-4841: chore: fix XSS in renderer (#875) · usememos/memos@64e5c34
Cross-site Scripting (XSS) - Stored in GitHub repository usememos/memos prior to 0.9.1.
@@ -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);
}
}
@@ -1,4 +1,3 @@
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>`;
};
@@ -1,4 +1,3 @@
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>`;
};
@@ -1,4 +1,3 @@
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>`;
};
@@ -1,4 +1,4 @@
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 {
0 comments on commit 64e5c34
Please sign in to comment.
Related news
Cross-site Scripting (XSS) - Stored in GitHub repository usememos/memos 0.9.0 and prior.