From: Senthil Kumaran Date: Thu, 2 Apr 2009 03:00:34 +0000 (+0000) Subject: Fixing the issue4860. Escaping embedded '"' character in js_output() method of Morsel. X-Git-Tag: v2.7a1~1607 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c730a6a1237a31d0ce89ab8fee2dea9af450a6ee;p=thirdparty%2FPython%2Fcpython.git Fixing the issue4860. Escaping embedded '"' character in js_output() method of Morsel. --- diff --git a/Lib/Cookie.py b/Lib/Cookie.py index b2f7427aa94f..1ccfd160a499 100644 --- a/Lib/Cookie.py +++ b/Lib/Cookie.py @@ -477,7 +477,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_cookie.py b/Lib/test/test_cookie.py index e7c0cf1cccb0..1cd538ce40d4 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""" """) - self.assertEqual(C.js_output(['path']), """ + self.assertEqual(C.js_output(['path']), r""" """)