Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Commit

Permalink
fix: manually parse the content disposition to preserve directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Sep 21, 2021
1 parent 544b04d commit 55e9e3f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion 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 55e9e3f

Please sign in to comment.