fix: decode URL-encoded filename from contentDisposition header (#1099)

This commit is contained in:
Krau authored and GitHub committed 2025-09-04 18:22:30 +08:00
1 parent 55e6bdc4f7
commit cfdcb586ee
3 files changed
+34 -2

No files matched your search

+3 -2
View File
@@ -23,6 +23,7 @@ import (
"github.com/GopeedLab/gopeed/internal/fetcher"
"github.com/GopeedLab/gopeed/pkg/base"
fhttp "github.com/GopeedLab/gopeed/pkg/protocol/http"
"github.com/GopeedLab/gopeed/pkg/util"
"github.com/xiaoqidun/setft"
"golang.org/x/sync/errgroup"
)
@@ -172,13 +173,13 @@ func (f *Fetcher) Resolve(req *base.Request) error {
filename = strings.Replace(filename, "UTF8", "UTF-8", 1)
file.Name, _ = decoder.Decode(filename)
} else {
file.Name = filename
file.Name = util.TryUrlQueryUnescape(filename)
}
} else {
substr := "attachment; filename="
index := strings.Index(contentDisposition, substr)
if index != -1 {
file.Name = contentDisposition[index+len(substr):]
file.Name = util.TryUrlQueryUnescape(contentDisposition[index+len(substr):])
}
}
}