[issue4860] js_output wrong for cookies with " characters

Noufal report at bugs.python.org
Tue Jan 6 22:44:11 CET 2009


New submission from Noufal <noufal at nibrahim.net.in>:

If a cookie is created with a " character in the content, the js_output
which is emitted is bad javascript. eg.
>>> import Cookie
>>> c=Cookie.Cookie('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
>>> print c
Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme; Version=1
>>> print c.js_output()

        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "Customer="WILE_E_COYOTE"; Path=/acme; Version=1";
        // end hiding -->
        </script>
        
>>> 

Also, the test_cookie tests (test_load) explicitly checks for this
(wrong) output.

I have attached a patch that seems to fix this or at the very least
produces the same Cookie settings whether the cookie is set using the
header or using javascript (I've verified this on firefox on Linux).

----------
components: Library (Lib), Tests
files: cookie.patch
keywords: patch
messages: 79292
nosy: noufal
severity: normal
status: open
title: js_output wrong for cookies with " characters
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file12625/cookie.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4860>
_______________________________________


More information about the Python-bugs-list mailing list