diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2009-04-02 03:00:34 +0000 |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2009-04-02 03:00:34 +0000 |
commit | c730a6a1237a31d0ce89ab8fee2dea9af450a6ee (patch) | |
tree | 2a2250447d2fb7558655801ce438f0acac106f08 | |
parent | 985951df7f05b8206c5c928a7783326ea942a874 (diff) | |
download | cpython-git-c730a6a1237a31d0ce89ab8fee2dea9af450a6ee.tar.gz |
Fixing the issue4860. Escaping embedded '"' character in js_output() method of Morsel.
-rw-r--r-- | Lib/Cookie.py | 2 | ||||
-rw-r--r-- | Lib/test/test_cookie.py | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/Lib/Cookie.py b/Lib/Cookie.py index b2f7427aa9..1ccfd160a4 100644 --- a/Lib/Cookie.py +++ b/Lib/Cookie.py @@ -477,7 +477,7 @@ class Morsel(dict): document.cookie = \"%s\"; // end hiding --> </script> - """ % ( self.OutputString(attrs), ) + """ % ( self.OutputString(attrs).replace('"',r'\"'), ) # end js_output() def OutputString(self, attrs=None): diff --git a/Lib/test/test_cookie.py b/Lib/test/test_cookie.py index e7c0cf1ccc..1cd538ce40 100644 --- a/Lib/test/test_cookie.py +++ b/Lib/test/test_cookie.py @@ -51,17 +51,17 @@ class CookieTests(unittest.TestCase): self.assertEqual(C.output(['path']), 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme') - self.assertEqual(C.js_output(), """ + self.assertEqual(C.js_output(), r""" <script type="text/javascript"> <!-- begin hiding - document.cookie = "Customer="WILE_E_COYOTE"; Path=/acme; Version=1"; + document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1"; // end hiding --> </script> """) - self.assertEqual(C.js_output(['path']), """ + self.assertEqual(C.js_output(['path']), r""" <script type="text/javascript"> <!-- begin hiding - document.cookie = "Customer="WILE_E_COYOTE"; Path=/acme"; + document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme"; // end hiding --> </script> """) |