Skip to content

Commit

Permalink
escape redirect urls
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Jan 7, 2025
1 parent 49d0e40 commit 71fc5c8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gateway/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,12 +906,12 @@ func handleProtocolHandlerRedirect(w http.ResponseWriter, r *http.Request, c *Co
webError(w, r, c, fmt.Errorf("uri query parameter scheme must be ipfs or ipns: %w", err), http.StatusBadRequest)
return true
}
path := u.Path

redirectURL := url.JoinPath("/", u.Scheme, u.Host, u.Path)

Check failure on line 910 in gateway/handler.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go this)

assignment mismatch: 1 variable but url.JoinPath returns 2 values

Check failure on line 910 in gateway/handler.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go this)

assignment mismatch: 1 variable but url.JoinPath returns 2 values

Check failure on line 910 in gateway/handler.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go next)

assignment mismatch: 1 variable but url.JoinPath returns 2 values

Check failure on line 910 in gateway/handler.go

View workflow job for this annotation

GitHub Actions / go-test / ubuntu (go next)

assignment mismatch: 1 variable but url.JoinPath returns 2 values

Check failure on line 910 in gateway/handler.go

View workflow job for this annotation

GitHub Actions / go-test / macos (go this)

assignment mismatch: 1 variable but url.JoinPath returns 2 values

Check failure on line 910 in gateway/handler.go

View workflow job for this annotation

GitHub Actions / go-test / macos (go this)

assignment mismatch: 1 variable but url.JoinPath returns 2 values

Check failure on line 910 in gateway/handler.go

View workflow job for this annotation

GitHub Actions / go-test / macos (go next)

assignment mismatch: 1 variable but url.JoinPath returns 2 values

Check failure on line 910 in gateway/handler.go

View workflow job for this annotation

GitHub Actions / go-test / macos (go next)

assignment mismatch: 1 variable but url.JoinPath returns 2 values
if u.RawQuery != "" { // preserve query if present
path = path + "?" + u.RawQuery
redirectURL += "?" + u.RawQuery
}

redirectURL := gopath.Join("/", u.Scheme, u.Host, path)
http.Redirect(w, r, redirectURL, http.StatusMovedPermanently)
return true
}
Expand Down

0 comments on commit 71fc5c8

Please sign in to comment.