fileupload: URL-escape output filename

If the source filename contains special characters like "%", we
would return them as-is in the final URL, and try to parse them as
a URL encoded escape sequence in the GET request.
This commit is contained in:
Simon Ser 2024-03-11 11:46:26 +01:00
parent f214e5a5aa
commit 7f66926c41

View file

@ -4,6 +4,7 @@ import (
"fmt"
"io"
"mime"
"net/url"
"os"
"path/filepath"
"strings"
@ -92,5 +93,5 @@ func (fs *fs) store(r io.Reader, username, mimeType, origBasename string) (outFi
return "", fmt.Errorf("failed to close file: %v", err)
}
return username + "/" + filepath.Base(f.Name()), nil
return url.PathEscape(username) + "/" + url.PathEscape(filepath.Base(f.Name())), nil
}