diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2009-04-02 03:02:03 +0000 |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2009-04-02 03:02:03 +0000 |
commit | 35b264dc1c3af077e3dfa4e61f001c86ef3ca3e2 (patch) | |
tree | f2b2e08c8d9c7a1e4884aaaf6e767c8d47c12a9e /Lib | |
parent | 9d949ec60a85cf844aabb32204a5d42efb7750e6 (diff) | |
download | cpython-35b264dc1c3af077e3dfa4e61f001c86ef3ca3e2.tar.gz |
Fixing the issue4860. Escaping the embedded '"' in the js_output method of Morsel class.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/http/cookies.py | 2 | ||||
-rw-r--r-- | Lib/test/test_http_cookies.py | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py index 03d1627de9..695161a380 100644 --- a/Lib/http/cookies.py +++ b/Lib/http/cookies.py @@ -392,7 +392,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_http_cookies.py b/Lib/test/test_http_cookies.py index 01017e15c0..158dd634b0 100644 --- a/Lib/test/test_http_cookies.py +++ b/Lib/test/test_http_cookies.py @@ -50,17 +50,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> """) |