mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
fix(security): fully escape forge HTML
This commit is contained in:
3 files changed
+22
-2
No files matched your search
@@ -33,7 +33,10 @@ function colorToTemplate(color?: number): FeishuTemplate {
|
||||
* up (a zero-width space after `<`) and shows as text.
|
||||
*/
|
||||
function noMentions(content: string): string {
|
||||
return content.replace(/<(\/?)(at)\b/gi, "<\u200b$1$2");
|
||||
// Escape every angle bracket, not only `<at`. Replacing just the mention
|
||||
// prefix still leaves values such as `<script` in Feishu markdown, where an
|
||||
// incomplete tag can be interpreted as HTML by the client.
|
||||
return content.replace(/</g, "<").replace(/>/g, ">");
|
||||
}
|
||||
|
||||
function mdText(content: string): { tag: "lark_md"; content: string } {
|
||||
|
||||
Reference in new issue
Block a user