Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: ServeMux should not cleanup requests path and redirect by default #19481

Closed
ipostelnik opened this issue Mar 9, 2017 · 1 comment
Closed

Comments

@ipostelnik
Copy link

ipostelnik commented Mar 9, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.7.3 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"

What did you do?

http.ServerMux always forces a redirect to cleaned up path (e.g. . and .. removed, empty path components removed, etc..). Specifically, removing an empty component can change the meaning of the URI. In a general case, the handlers should be able to see raw requested URI and decide how the want to handle it. FileSystem handler may want to cleanup paths in this way, but for other cases this is unexpected behavior.

What did you expect to see?

Request for /foo//bar gets redirected to /foo/bar.

What did you see instead?

Request for /foo//bar gets dispatched to the proper handler that matches this URI without cleanup.

@bradfitz
Copy link
Contributor

bradfitz commented Mar 9, 2017

Sorry, it's too late to change this, regardless of whether it's a good idea or not.

It's also a documented feature:

ServeMux also takes care of sanitizing the URL request path, redirecting any request containing . or .. elements or repeated slashes to an equivalent, cleaner URL.

There are hundreds of alternative muxes available. See https://godoc.org/ to find some.

@bradfitz bradfitz closed this as completed Mar 9, 2017
@golang golang locked and limited conversation to collaborators Mar 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants