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/url: clarify in docs that RawPath is not always set by Parse() #29662

Closed
clausti opened this issue Jan 10, 2019 · 2 comments
Closed

net/url: clarify in docs that RawPath is not always set by Parse() #29662

clausti opened this issue Jan 10, 2019 · 2 comments
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@clausti
Copy link

clausti commented Jan 10, 2019

The documentation for the URL type states that

The Parse function sets both Path and RawPath in the URL it returns, and URL's String method uses RawPath if it is a valid encoding of Path, by calling the EscapedPath method. [emphasis added]

which makes it sound like it will always be set but this is not the case.

In the parse() function called by Parse() and ParseRequestURI(), a comment states that it sets Path

and, optionally, RawPath. [...] We don't want to set it if the default escaping of Path is equivalent, to help make sure that people don't rely on it in general. [emphasis added]

For example:
Parsing "/foo" sets Path as "/foo" but does not set RawPath.
Parsing "%2Ffoo" sets the same Path, "/foo", but also sets RawPath as "%2Ffoo".
(see: https://play.golang.org/p/8R2_iCLDdrS)

This is unexpected behavior based on the public package documentation, which should be updated.

@dmitshur dmitshur added this to the Go1.13 milestone Apr 24, 2019
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 24, 2019
@dmitshur
Copy link
Contributor

/cc @rsc @bradfitz (per net/url owners)

@gopherbot
Copy link

Change https://golang.org/cl/177900 mentions this issue: net/url: clarify that RawPath is optionally set

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants