This commit is contained in:
Administrator
2024-09-05 18:16:17 +08:00
parent 688c516c9f
commit 88f37ecc2d
9 changed files with 170 additions and 26 deletions

11
filter/js.go Normal file
View File

@ -0,0 +1,11 @@
package filter
import "regexp"
// FilterScriptTags 使用正则表达式过滤 HTML 文本中的 <script> 标签(不区分大小写)
func FilterScriptTags(input string) string {
// 正则表达式匹配 <script> 标签及其内容,不区分大小写
re := regexp.MustCompile(`(?i)<script[^>]*>.*?</script>`)
// 替换匹配的部分为空字符串
return re.ReplaceAllString(input, "")
}