mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-08 09:30:27 +00:00
fix: resolve http non encode attachment filename (#975)
This commit is contained in:
4 files changed
+39
-2
No files matched your search
@@ -174,6 +174,12 @@ func (f *Fetcher) Resolve(req *base.Request) error {
|
||||
} else {
|
||||
file.Name = filename
|
||||
}
|
||||
} else {
|
||||
substr := "attachment; filename="
|
||||
index := strings.Index(contentDisposition, substr)
|
||||
if index != -1 {
|
||||
file.Name = contentDisposition[index+len(substr):]
|
||||
}
|
||||
}
|
||||
}
|
||||
// get file filePath by URL
|
||||
@@ -610,6 +616,14 @@ func (f *Fetcher) buildClient() *http.Client {
|
||||
}
|
||||
}
|
||||
|
||||
func decodeMangledString(mangled string) string {
|
||||
rawBytes := make([]byte, 0, len(mangled)*3)
|
||||
for _, r := range mangled {
|
||||
rawBytes = append(rawBytes, byte(r))
|
||||
}
|
||||
return string(rawBytes)
|
||||
}
|
||||
|
||||
type fetcherData struct {
|
||||
Connections []*connection
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user