mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-11-26 22:20:18 +01:00
Merge pull request #125 from aspacca/ISSUE-109
ISSUE-109 fragment and query separators not escaped
This commit is contained in:
commit
8a0e3d39f2
1 changed files with 16 additions and 1 deletions
|
@ -411,7 +411,22 @@ func (s *Server) putHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
|
||||||
relativeURL, _ := url.Parse(path.Join(token, filename))
|
relativeURL, _ := url.Parse(path.Join(token, filename))
|
||||||
fmt.Fprint(w, getURL(r).ResolveReference(relativeURL).String())
|
|
||||||
|
fmt.Fprint(w, escapeFilename(r, relativeURL))
|
||||||
|
}
|
||||||
|
|
||||||
|
func escapeFilename(r *http.Request, u *url.URL) string {
|
||||||
|
if u.RawQuery != "" {
|
||||||
|
u.Path = fmt.Sprintf("%s?%s", u.Path, url.QueryEscape(u.RawQuery))
|
||||||
|
u.RawQuery = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if u.Fragment != "" {
|
||||||
|
u.Path = fmt.Sprintf("%s#%s", u.Path, u.Fragment)
|
||||||
|
u.Fragment = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return getURL(r).ResolveReference(u).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getURL(r *http.Request) *url.URL {
|
func getURL(r *http.Request) *url.URL {
|
||||||
|
|
Loading…
Reference in a new issue