User url.Parse instead of url.ParseRequestURI

url.ParseRequestURI assumes the URL does not contain a fragment
identifier.  However, this is not disallowed. So we should use
url.Parse instead.

Related issue: #45
This commit is contained in:
Daan Sprenkels 2020-04-22 16:11:32 +02:00
parent 63a588ba59
commit 42ccc18002

View File

@ -265,7 +265,7 @@ func (rl *rushlink) newPasteHandlerURLEncoded(w http.ResponseWriter, r *http.Req
} }
func (rl *rushlink) newRedirectPasteHandler(w http.ResponseWriter, r *http.Request, rawurl string) { func (rl *rushlink) newRedirectPasteHandler(w http.ResponseWriter, r *http.Request, rawurl string) {
userURL, err := url.ParseRequestURI(rawurl) userURL, err := url.Parse(rawurl)
if err != nil { if err != nil {
msg := fmt.Sprintf("invalid url (%v): %v", err, rawurl) msg := fmt.Sprintf("invalid url (%v): %v", err, rawurl)
rl.renderError(w, r, http.StatusBadRequest, msg) rl.renderError(w, r, http.StatusBadRequest, msg)