diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-09-17 11:25:37 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-09-18 15:16:11 +0200 |
commit | 6be6752c8a0175210f0f277282e212a2cec4b4f2 (patch) | |
tree | 49318d8adea669126f9cd4a26f830209e1fd2d98 /commands/server.go | |
parent | 8e9dce1092133a44795062dbfdc917468c0c7056 (diff) |
server: Fix redirects when file path contains bytes > 0x80
Fixes #10287
Diffstat (limited to 'commands/server.go')
-rw-r--r-- | commands/server.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/commands/server.go b/commands/server.go index 7689f03db..06b7612fc 100644 --- a/commands/server.go +++ b/commands/server.go @@ -400,13 +400,14 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, net.Listener, string } // Ignore any query params for the operations below. - requestURI := strings.TrimSuffix(r.RequestURI, "?"+r.URL.RawQuery) + requestURI, _ := url.PathUnescape(strings.TrimSuffix(r.RequestURI, "?"+r.URL.RawQuery)) for _, header := range f.c.serverConfig.MatchHeaders(requestURI) { w.Header().Set(header.Key, header.Value) } if redirect := f.c.serverConfig.MatchRedirect(requestURI); !redirect.IsZero() { + // fullName := filepath.Join(dir, filepath.FromSlash(path.Clean("/"+name))) doRedirect := true // This matches Netlify's behaviour and is needed for SPA behaviour. // See https://docs.netlify.com/routing/redirects/rewrites-proxies/ |