mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
refactor: 大规模代码整理与功能优化
1. 重构后端API路由、CRUD与模块结构,整合日志管理,移除废弃demo代码 2. 优化前端组件类型定义、样式与路由配置,修复权限判断逻辑 3. 调整默认排序规则、滚动条样式与工具类函数,更新依赖与配置文件 4. 修复多处类型不匹配与默认值问题,完善表单与菜单验证逻辑
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import bleach
|
||||
from bleach.css_sanitizer import CSSSanitizer
|
||||
|
||||
ALLOWED_TAGS = [
|
||||
"a",
|
||||
@@ -112,47 +113,7 @@ def sanitize_html(content: str) -> str:
|
||||
content,
|
||||
tags=ALLOWED_TAGS,
|
||||
attributes=ALLOWED_ATTRIBUTES,
|
||||
css_sanitizer=CSSSanitizer(allowed_css_properties=ALLOWED_STYLES),
|
||||
strip=True,
|
||||
strip_comments=True,
|
||||
)
|
||||
|
||||
|
||||
def sanitize_html_with_styles(content: str) -> str:
|
||||
"""
|
||||
清理 HTML 内容;标签与属性白名单与 `sanitize_html` 一致。
|
||||
|
||||
参数:
|
||||
- content (str): 需要清理的 HTML 内容。
|
||||
|
||||
返回:
|
||||
- str: 清理后的 HTML 字符串。
|
||||
|
||||
说明:
|
||||
- `ALLOWED_STYLES` 供后续接入 bleach 样式清洗时使用,当前实现与 `sanitize_html` 相同。
|
||||
"""
|
||||
if not content:
|
||||
return content
|
||||
|
||||
return bleach.clean(
|
||||
content,
|
||||
tags=ALLOWED_TAGS,
|
||||
attributes=ALLOWED_ATTRIBUTES,
|
||||
strip=True,
|
||||
strip_comments=True,
|
||||
)
|
||||
|
||||
|
||||
def strip_all_tags(content: str) -> str:
|
||||
"""
|
||||
移除所有 HTML 标签,只保留纯文本。
|
||||
|
||||
参数:
|
||||
- content (str): 需要处理的 HTML 内容
|
||||
|
||||
返回:
|
||||
- str: 纯文本内容
|
||||
"""
|
||||
if not content:
|
||||
return content
|
||||
|
||||
return bleach.clean(content, tags=[], attributes={}, strip=True)
|
||||
|
||||
Reference in New Issue
Block a user