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

fix: manually parse the content disposition to preserve directories #42

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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