http.URLEscape and space character

1,743 views
Skip to first unread message

Changjian Gao

unread,
May 17, 2011, 3:18:09 AM5/17/11
to golan...@googlegroups.com
Hi, guys.

According to RFC 2396 2.4.1 section, space character should be escaped to "%20", but current implementation of http package translate to "+". Can anybody explain why?

Thanks.

Changjian Gao

unread,
May 17, 2011, 3:18:14 AM5/17/11
to golan...@googlegroups.com

Arlen Cuss

unread,
May 17, 2011, 3:46:14 AM5/17/11
to golan...@googlegroups.com
This may explain some: http://en.wikipedia.org/wiki/Percent-encoding#The_application.2Fx-www-form-urlencoded_type

2011/5/17 Changjian Gao <gaocha...@gmail.com>

Hi, guys.

According to RFC 2396 2.4.1 section, space character should be escaped to "%20", but current implementation of http package translate to "+". Can anybody explain why?

Thanks.



--
Arlen Cuss
Software Engineer
Noble Samurai

ABOOBACKER PULLISSERI

unread,
May 17, 2011, 7:37:44 AM5/17/11
to golang-nuts
yes, but when i use the functions , the following error occur

undefined: regexp.FindStringSubmatch

On May 17, 12:46 pm, Arlen Cuss <ar...@noblesamurai.com> wrote:
> This may explain some:http://en.wikipedia.org/wiki/Percent-encoding#The_application.2Fx-www...
>
> 2011/5/17 Changjian Gao <gaochangj...@gmail.com>

chris dollin

unread,
May 17, 2011, 7:48:25 AM5/17/11
to ABOOBACKER PULLISSERI, golang-nuts
On 17 May 2011 12:37, ABOOBACKER PULLISSERI <aboobac...@gmail.com> wrote:
> yes, but when i use the functions , the following error occur
>
> undefined: regexp.FindStringSubmatch

FindStringSubmatch is a method on the type *Regexp, not a function
in the package regexp. The thing before the dot has to be some
value of the *Regexp type.

Chris

--
Chris "allusive" Dollin

Changjian Gao

unread,
May 18, 2011, 9:47:23 AM5/18/11
to Arlen Cuss, golan...@googlegroups.com
So, the reason is HTML specification outdated, you guys must obey the spec, rather than the RFC, right?
--
Home: http://www.xiaogaozi.org/
Blog: http://blog.xiaogaozi.org/
Twitter: http://twitter.com/xiaogaozi

Russ Cox

unread,
May 18, 2011, 9:55:53 AM5/18/11
to Changjian Gao, Arlen Cuss, golan...@googlegroups.com
On Wed, May 18, 2011 at 09:47, Changjian Gao <gaocha...@gmail.com> wrote:
> So, the reason is HTML specification outdated, you guys must obey the spec,
> rather than the RFC, right?

No. There are two kinds of escaping that happen in URLs.
In the path part of the URL a space must be escaped as %20.
In the query part (after the ?) a space can be escaped as %20 or +.

The godoc for http.URLEscape makes clear that it is applying
the query escaping form.

Russ

Changjian Gao

unread,
May 18, 2011, 11:03:49 AM5/18/11
to Russ Cox, Arlen Cuss, golan...@googlegroups.com
Very thanks, Russ.

But I still have some confusion about why other languages escape space as %20, like JavaScript's encodeURI(), or Python's urllib.quote(). Maybe I think too much, :)

Dmitry Chestnykh

unread,
May 18, 2011, 1:22:00 PM5/18/11
to golan...@googlegroups.com, Russ Cox, Arlen Cuss
Python has:
urllib.quote_plus(string[safe])
Like quote(), but also replaces spaces by plus signs, as required for quoting HTML form values when building up a query string to go into a URL. Plus signs in the original string are escaped unless they are included in safe. It also does not havesafe default to '/'.
-Dmitry

Changjian Gao

unread,
May 18, 2011, 10:14:25 PM5/18/11
to golan...@googlegroups.com, Russ Cox, Arlen Cuss
How could I miss this? Thanks, Dmitry.
Reply all
Reply to author
Forward
0 new messages