[go-nuts] Re: URL parsing with special characters.

2020-04-30 Thread Brian Candler
In a URL, the percent sign should appear as %25  (% marks the start of a 
hex-encoded character)
https://play.golang.org/p/gMC1tdpJER4

The URL as shown is invalid.

-- 
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/5b4461d5-d635-430c-8a7c-95277364773f%40googlegroups.com.


[go-nuts] Re: URL parsing with special characters.

2020-05-01 Thread Vivek
Thanks everyone.

I am using "github.com/jlaffaye/ftp" library which returned unescaped file 
names when doing directory listing. I constructed the full url by doing 

filePath = "ftp://user:pass@192.168.0.1/path/"; + "file%ver3.txt 
"
 
and later tried to parse the url with url.Parse function somewhere else in 
the code which failed.

I am now calling url.Escape on the file names before appending. 

Regards,
Vivek



On Thursday, 30 April 2020 22:35:45 UTC+5:30, Vivek wrote:
>
> I am trying to parse  a url similar to "ftp://
> user:pass@192.168.0.1/path/file%ver3.txt 
> "
>  
> using `net/url` Parse function but I am getting a error
>
> `parse "ftp://user:pass@192.168.0.1/path/file%ver3.txt": invalid URL 
> escape "%ve"`
>
> https://play.golang.org/p/HE6zlDeIbyq 
> 
>
> The same path parses fine with python(urllib.parse.urlparse and C# URI). 
>
> I appreciate any help on this.
>
> Regards,
> Vivek
>

-- 
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/a55c65be-fce0-43d7-95ea-2d33cb7746dc%40googlegroups.com.


Re: [go-nuts] Re: URL parsing with special characters.

2020-04-30 Thread Ian Lance Taylor
On Thu, Apr 30, 2020 at 11:09 AM Brian Candler  wrote:
>
> In a URL, the percent sign should appear as %25  (% marks the start of a 
> hex-encoded character)
> https://play.golang.org/p/gMC1tdpJER4
>
> The URL as shown is invalid.

I *think* you are saying that the u.Path field should use %25 rather
than plain %.  But as the documentation says
(https://golang.org/pkg/net/url/#URL) the Path field is the decoded
form.  If you simply print the URL, you will see %25.  Consider
https://play.golang.org/p/Z0eUYfkm3PR.

If you mean something else, can you explain?  Thanks.

Ian

-- 
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/CAOyqgcXciAhj1Ommek%2B3-NYr54wqUnnAPyjk4fGg7uE45UZ_Gg%40mail.gmail.com.


Re: [go-nuts] Re: URL parsing with special characters.

2020-04-30 Thread Brian Candler
On Thursday, 30 April 2020 23:04:01 UTC+1, Ian Lance Taylor wrote:
>
> On Thu, Apr 30, 2020 at 11:09 AM Brian Candler  > wrote: 
> > 
> > In a URL, the percent sign should appear as %25  (% marks the start of a 
> hex-encoded character) 
> > https://play.golang.org/p/gMC1tdpJER4 
> > 
> > The URL as shown is invalid. 
>
> I *think* you are saying that the u.Path field should use %25 rather 
> than plain %.



No: I'm just saying the library is working correctly, by rejecting the 
invalid input that the OP gave.

If the input URL is correct to file%25ver3, then the parsed u.Path contains 
file%ver3 as expected.

-- 
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/453fe1df-34b0-4156-8d9c-5eaa62f485aa%40googlegroups.com.