From: Senthil Kumaran Date: Thu, 2 Apr 2009 03:02:03 +0000 (+0000) Subject: Fixing the issue4860. Escaping the embedded '"' in the js_output method of Morsel... X-Git-Tag: v3.1a2~75 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3e2ea79bdaa6be1337b34f8da03f8c42dfe43d2f;p=python Fixing the issue4860. Escaping the embedded '"' in the js_output method of Morsel class. --- 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 --> - """ % ( 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""" """) - self.assertEqual(C.js_output(['path']), """ + self.assertEqual(C.js_output(['path']), r""" """)