﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19641	Cookie encoding inconsistency	kirpit	nobody	"Django is encoding cookie values and if, only if any of its value is encoded, wrapping the entire value within double quotes.

`django/http/__init__.py` starts from the line `#84` (for 1.4.3):
  {{{#!python
  # If encoded now contains any quoted chars, we need double quotes
  # around the whole string.
  if ""\\"" in encoded and not encoded.startswith('""'):
    encoded = '""' + encoded + '""'
  }}}

That means, the value `hello` will be stored as `hello` but `hello world` will be stored as `""hello world""`.

I believe this is totally inconsistent and difficult to handle from client side. For example, you simply cannot use [https://github.com/carhartl/jquery-cookie jquery.cookie] to get the exact value without writing some double quotes checking javascript code.

If you use jquery.cookie with its default values (`$.cookie.raw = false;` and `$.cookie.json = false;`) you get the server-side set value with double quotes around it (as in `var value = '""hello world""';`)

If you use it with `$.cookie.json = true;`, you get the double quoted values fine (as in `var value = ""hello world"";`) but you get syntax error (for `hello`) because it is trying `JSON.parse('hello')`, which is not a valid JSON string."	Bug	closed	HTTP handling	1.4	Release blocker	invalid	cookie, encoding		Unreviewed	0	0	0	0	0	0
