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:
parent
f214e5a5aa
commit
7f66926c41
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue