Rails cookie encoding incompatible with JavaScript decodeURIComponent

jquery.cookie retrieves a value using decodeURIComponent. https://github.com/carhartl/jquery-cookie/blob/master/jquery.cookie.js#L89

Rails saves the cookie by calling

@set_cookies.each { |k, v| ::Rack::Utils.set_cookie_header!(headers, k, v) 
if write_cookie?(v) }

As you can see, using a rack replaces spaces with a plus sign.

https://github.com/rack/rack/blob/master/lib/rack/utils.rb#L18

If I use encodeURIComponent Javascript, then the encoded value for 'hello world' is

"Hello% 20world"

However, the rails store the cookie value as

hello + world

Who is right?

Where can I see what the spec says to keep the cookie value.

+5
1

, , .

Cookies RFC2109: http://www.ietf.org/rfc/rfc2109.txt RFC2068 ..: http://www.ietf.org/rfc/rfc2068.txt

, , cookie. , , . , .

cookie jQuery "raw", decodeURIComponent, , .

+2

All Articles