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: encoding is broken as per RFC wrt @ #9594

Closed
devonjones opened this issue Jan 15, 2015 · 1 comment
Closed

net/url: encoding is broken as per RFC wrt @ #9594

devonjones opened this issue Jan 15, 2015 · 1 comment

Comments

@devonjones
Copy link

https://tools.ietf.org/html/rfc3986 2.2: Reserved characters: @ is a reserved character, the only place it should be in the url is between username@host

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

  • Current version of the go playground

What operating system and processor architecture are you using?

  • Current version of the go playground

What did you do?
What did you expect to see?
What did you see instead?

http://play.golang.org/p/WvjfmMKJIw

package main

import (
    "fmt"
    "net/url"
)

func main() {

    var Url *url.URL
    Url, err := url.Parse("http://www.example.com")
    if err != nil {
        panic("boom")
    }

    Url.Path += "/users/1/recipients/devon.jones@sendgrid.com"
    fmt.Printf("Encoded URL is %q\n", Url.String())
}
Encoded URL is "http://www.example.com/users/1/recipients/devon.jones@sendgrid.com"

shows that if I url encode with @ in the path, it leaves it. But if I use other reserved characters, like ?, it will properly encode them:

http://play.golang.org/p/FT-JyJ-DnG

package main

import (
    "fmt"
    "net/url"
)

func main() {

    var Url *url.URL
    Url, err := url.Parse("http://www.example.com")
    if err != nil {
        panic("boom")
    }

    Url.Path += "/users/1/recipients/devon.jones?sendgrid.com"
    fmt.Printf("Encoded URL is %q\n", Url.String())
}
Encoded URL is "http://www.example.com/users/1/recipients/devon.jones%3Fsendgrid.com"
@devonjones
Copy link
Author

Found that section 3.3 allows for it explicitly in path, closing issue

@mikioh mikioh changed the title URL encoding is broken as per RFC wrt @ net/url: encoding is broken as per RFC wrt @ Jan 15, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

2 participants