Skip to content

Commit

Permalink
Double quote filename to account for filenames with commas
Browse files Browse the repository at this point in the history
  • Loading branch information
TevinAdams committed Jan 3, 2025
1 parent 8188838 commit 57fedfb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"io"
"path"
"strconv"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -116,9 +117,11 @@ func (s *S3) TempFileSystem() *afero.Afero {
func (s *S3) PresignedURL(key string, contentType string, filename string) (string, error) {
namespacedKey := path.Join(s.keyNamespace, key)
presignClient := s3.NewPresignClient(s.client)
// Double quote the filename to be able to handle filenames with commas in them
quotedFilename := strconv.Quote(filename)

filenameBuffer := make([]byte, 0)
for _, r := range filename {
for _, r := range quotedFilename {
if encodedRune, ok := charmap.ISO8859_1.EncodeRune(r); ok {
filenameBuffer = append(filenameBuffer, encodedRune)
}
Expand Down

0 comments on commit 57fedfb

Please sign in to comment.