fix(rules): fix unicode encoding error in rule set export filename
Use RFC 5987 filename*=UTF-8'' format for Content-Disposition header to support Chinese characters in exported filename
This commit is contained in:
parent
82b9733e92
commit
a4b7efb1c9
|
|
@ -444,10 +444,14 @@ async def export_rule_set(
|
||||||
"export_version": "1.0",
|
"export_version": "1.0",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 使用 URL 编码处理中文文件名
|
||||||
|
from urllib.parse import quote
|
||||||
|
encoded_filename = quote(f"{rule_set.name}.json")
|
||||||
|
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content=export_data,
|
content=export_data,
|
||||||
headers={
|
headers={
|
||||||
"Content-Disposition": f'attachment; filename="{rule_set.name}.json"'
|
"Content-Disposition": f"attachment; filename*=UTF-8''{encoded_filename}"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue