Invalid URL escape while parsing URL

hello everybody.

I was trying to parse an url that contins in its “path” field the following string:


and I get this error:

 invalid URL escape "%%2"

I looked around to see if the an URL could contain “%%” or not and I believe it could, please tell me if I am wrong on this point.

if the string “%%2” is acceptable in an URL could there be something wrong in the net/url parsing code?

Is the actual name of this file Segment%(15197306101420000).ts?

What code do you use?

Use QueryEscape to escape the string, so it can be safely placed inside a URL query before you parse the url.

func main() {

    s := "" // assuming that url contains '%%2'

    qs := url.QueryEscape(s)
    u, err := url.Parse(qs)

    if err != nil {

    fmt.Println("scheme: ",u.Path)
1 Like

The output of this code is


Is this what is requested or shall the %28 and %29 be decoded to ( and )?

1 Like

It mentioned, if there’s something wrong in the net/url parsing code. so the code example shows that there’s nothing wrong with net/url, just add some implementation query escape before parsing url.

1 Like


that I am sure will help :slight_smile:

Thank you

I checked with my coworkers and as you mentioned %28 should be translated as an open bracket.

It seems that some user agents don’t cope well with those urls.

Thanks for the help

Yeah that’s right %28 should be understood as a bracket.

Nothing wrong with the net/url code.

Thank you

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.