fix: filename truncation for HTML-encoded ampersands in Content-Disposition (#1215)

This commit is contained in:
Copilot authored and GitHub committed 2026-01-05 22:56:04 +08:00
1 parent 6756d82ffa
commit abd16d5326
4 files changed
+303 -5

No files matched your search

+24
View File
@@ -139,6 +139,30 @@ func TestFetcher_Resolve(t *testing.T) {
},
},
}, t)
// Test filename with HTML-encoded ampersand (fixes issue with & being truncated)
// Before fix: "查询处理&优化.pptx" -> "查询处理&amp" (truncated at semicolon)
// After fix: correctly decoded to "查询处理&优化.pptx"
testResolve(test.StartTestCustomServer, "ampersand-encoded", &base.Resource{
Size: test.BuildSize,
Range: false,
Files: []*base.FileInfo{
{
Name: "查询处理&优化.pptx",
Size: test.BuildSize,
},
},
}, t)
// Test unquoted filename with HTML-encoded ampersand
testResolve(test.StartTestCustomServer, "ampersand-unquoted", &base.Resource{
Size: test.BuildSize,
Range: false,
Files: []*base.FileInfo{
{
Name: "test&file.txt",
Size: test.BuildSize,
},
},
}, t)
// Test URL without file path - should use domain/host as filename
listener := test.StartTestRootServer()