mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-07 09:00:47 +00:00
fix: decode URL-encoded filename from contentDisposition header (#1099)
This commit is contained in:
3 files changed
+34
-2
No files matched your search
@@ -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):])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user