Skip to content

Commit

Permalink
fix: manually parse the content disposition to preserve directories
Browse files Browse the repository at this point in the history
fixes ipfs/kubo#8445


This commit was moved from ipfs/go-ipfs-files@55e9e3f
  • Loading branch information
Stebalien committed Sep 21, 2021
1 parent 5c40acb commit ecf58d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion files/multipartfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ func (w *multipartWalker) nextFile() (Node, error) {

// fileName returns a normalized filename from a part.
func fileName(part *multipart.Part) string {
filename := part.FileName()
v := part.Header.Get("Content-Disposition")
_, params, err := mime.ParseMediaType(v)
if err != nil {
return ""
}
filename := params["filename"]
if escaped, err := url.QueryUnescape(filename); err == nil {
filename = escaped
} // if there is a unescape error, just treat the name as unescaped
Expand Down

0 comments on commit ecf58d5

Please sign in to comment.