Skip to content

Commit

Permalink
fix!: query escape abspath header
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Aug 15, 2023
1 parent b96767c commit 8fb846e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ The following emojis are used to highlight certain changes:

### Fixed

* 🛠 `MultiFileReader` has been updated to escape the absolute paths due to the regression
found in [`net/textproto`](https://github.com/golang/go/issues/60674). This is no longer
compatible with previous versions when using files that have binary characters in their
name.

### Security

## [v0.11.0]
Expand Down
2 changes: 1 addition & 1 deletion files/multifilereader.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (mfr *MultiFileReader) Read(buf []byte) (written int, err error) {

header.Set("Content-Type", contentType)
if rf, ok := entry.Node().(FileInfo); ok {
header.Set("abspath", rf.AbsPath())
header.Set("abspath", url.QueryEscape(rf.AbsPath()))
}

_, err := mfr.mpWriter.CreatePart(header)
Expand Down
7 changes: 6 additions & 1 deletion files/multipartfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ func (w *multipartWalker) nextFile() (Node, error) {

return NewLinkFile(string(out), nil), nil
default:
abspath, err := url.QueryUnescape(part.Header.Get("abspath"))
if err != nil {
return nil, err
}

Check warning on line 106 in files/multipartfile.go

View check run for this annotation

Codecov / codecov/patch

files/multipartfile.go#L105-L106

Added lines #L105 - L106 were not covered by tests

return &ReaderFile{
reader: part,
abspath: part.Header.Get("abspath"),
abspath: abspath,
}, nil
}
}
Expand Down

0 comments on commit 8fb846e

Please sign in to comment.