mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: fix XSS in renderer (#880)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { marked } from "..";
|
import { marked } from "..";
|
||||||
import Link from "./Link";
|
import Link from "./Link";
|
||||||
|
import PlainText from "./PlainText";
|
||||||
|
|
||||||
export const BOLD_REG = /\*\*(.+?)\*\*/;
|
export const BOLD_REG = /\*\*(.+?)\*\*/;
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
|
|||||||
return rawStr;
|
return rawStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedContent = marked(matchResult[1], [], [Link]);
|
const parsedContent = marked(matchResult[1], [], [Link, PlainText]);
|
||||||
return `<strong>${parsedContent}</strong>`;
|
return `<strong>${parsedContent}</strong>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { marked } from "..";
|
import { marked } from "..";
|
||||||
import Link from "./Link";
|
import Link from "./Link";
|
||||||
|
import PlainText from "./PlainText";
|
||||||
|
|
||||||
export const BOLD_EMPHASIS_REG = /\*\*\*(.+?)\*\*\*/;
|
export const BOLD_EMPHASIS_REG = /\*\*\*(.+?)\*\*\*/;
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
|
|||||||
return rawStr;
|
return rawStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedContent = marked(matchResult[1], [], [Link]);
|
const parsedContent = marked(matchResult[1], [], [Link, PlainText]);
|
||||||
return `<strong><em>${parsedContent}</em></strong>`;
|
return `<strong><em>${parsedContent}</em></strong>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { marked } from "..";
|
import { marked } from "..";
|
||||||
import Link from "./Link";
|
import Link from "./Link";
|
||||||
|
import PlainText from "./PlainText";
|
||||||
|
|
||||||
export const EMPHASIS_REG = /\*(.+?)\*/;
|
export const EMPHASIS_REG = /\*(.+?)\*/;
|
||||||
|
|
||||||
@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
|
|||||||
return rawStr;
|
return rawStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedContent = marked(matchResult[1], [], [Link]);
|
const parsedContent = marked(matchResult[1], [], [Link, PlainText]);
|
||||||
return `<em>${parsedContent}</em>`;
|
return `<em>${parsedContent}</em>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@ import Bold from "./Bold";
|
|||||||
import { marked } from "..";
|
import { marked } from "..";
|
||||||
import InlineCode from "./InlineCode";
|
import InlineCode from "./InlineCode";
|
||||||
import BoldEmphasis from "./BoldEmphasis";
|
import BoldEmphasis from "./BoldEmphasis";
|
||||||
|
import PlainText from "./PlainText";
|
||||||
|
|
||||||
export const LINK_REG = /\[(.*?)\]\((.+?)\)+/;
|
export const LINK_REG = /\[(.*?)\]\((.+?)\)+/;
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ const renderer = (rawStr: string): string => {
|
|||||||
if (!matchResult) {
|
if (!matchResult) {
|
||||||
return rawStr;
|
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>`;
|
return `<a class='link' target='_blank' rel='noreferrer' href='${escape(matchResult[2])}'>${parsedContent}</a>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user