On Fri, Mar 4, 2022 at 2:12 PM Jochen Voss <jochen.v...@gmail.com> wrote:
> If I convert an url.URL to a string and then parse the result, am I meant > to get back the original url? > I don't think so. String() returns an escaped URL and in general, there are multiple valid escaped forms of any URL. So, by necessity, there are different URLs which return the same String() result. The documentation points that out: https://pkg.go.dev/net/url#URL.EscapedPath > While playing with the new fuzzer I found that in practise this is not > the case, > but I'm not sure whether this is due to bugs, or whether this is expected. > > The affected URLs are of course all silly urls, chosen by the fuzzer. > Example: https://go.dev/play/p/VFe0MbBty3r > For this specific example, there is also this sentence in the docs: Trying to parse a hostname and path without a scheme is invalid but may not > necessarily return an error, due to parsing ambiguities. https://pkg.go.dev/net/url#Parse I don't know terribly much about the actual URL format, but this sounds to me, that the parsing result for that string is not actually well-defined anyway. > All the best, > Jochen > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/7a45513b-c0b3-457e-9f3b-3360204a713en%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/7a45513b-c0b3-457e-9f3b-3360204a713en%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfFzpdUF%3D-KZ1hkrcR3JUfkUCa2QeumN%3DVU87PtmupWoVg%40mail.gmail.com.