ZHIWEI666 commited on
Commit
410cd32
·
verified ·
1 Parent(s): 1825c81

Delete xss_filter.py

Browse files
Files changed (1) hide show
  1. xss_filter.py +0 -25
xss_filter.py DELETED
@@ -1,25 +0,0 @@
1
- import bleach
2
-
3
- # 定义允许的标签和属性
4
- ALLOWED_TAGS = ['p', 'img', 'a', 'br', 'b', 'i', 'u']
5
- ALLOWED_ATTRS = {
6
- 'img': ['src', 'alt'],
7
- 'a': ['href', 'target']
8
- }
9
-
10
- def clean_html(html_content):
11
- """
12
- 清理 HTML 内容,防止 XSS 攻击
13
-
14
- Args:
15
- html_content (str): 需要清理的 HTML 内容
16
-
17
- Returns:
18
- str: 清理后的安全 HTML 内容
19
- """
20
- return bleach.clean(
21
- html_content,
22
- tags=ALLOWED_TAGS,
23
- attributes=ALLOWED_ATTRS,
24
- strip=True
25
- )