mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-14 21:20:48 +08:00
fix(CI): tg notify error
This commit is contained in:
+13
-9
@@ -92,15 +92,19 @@ async function sendTelegramNotification() {
|
||||
function sanitizeTelegramHTML(content) {
|
||||
// Telegram supports: b, strong, i, em, u, ins, s, strike, del,
|
||||
// a, code, pre, blockquote, tg-spoiler, tg-emoji
|
||||
const allowedTags =
|
||||
/^\/?(b|strong|i|em|u|ins|s|strike|del|a|code|pre|blockquote|tg-spoiler|tg-emoji)(\s|>|$)/i
|
||||
return content.replace(/<\/?[^>]*>/g, (tag) => {
|
||||
const inner = tag.replace(/^<\/?/, '').replace(/>$/, '')
|
||||
if (allowedTags.test(inner) || allowedTags.test(tag.slice(1))) {
|
||||
return tag
|
||||
}
|
||||
// Escape unsupported tags so they display as text
|
||||
return tag.replace(/</g, '<').replace(/>/g, '>')
|
||||
const allowedTag =
|
||||
/^<\/?(?:b|strong|i|em|u|ins|s|strike|del|a|code|pre|blockquote|tg-spoiler|tg-emoji)(?:\s[^<>]*)?>$/i
|
||||
// Match a well-formed tag (name first, no nested angle brackets) OR a lone
|
||||
// '<'/'>'. Matching lone brackets is what keeps a stray '<' in the changelog
|
||||
// (e.g. "原始配置 < Merge") from greedily swallowing the next real tag and
|
||||
// leaving its closing tag orphaned ("Unexpected end tag").
|
||||
return content.replace(/<\/?[a-z][^<>]*>|[<>]/gi, (token) => {
|
||||
if (token === '<') return '<'
|
||||
if (token === '>') return '>'
|
||||
// Keep supported tags; escape everything else so it displays as text.
|
||||
return allowedTag.test(token)
|
||||
? token
|
||||
: token.replace(/</g, '<').replace(/>/g, '>')
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user