[Python-checkins] r71030 - in python/branches/py3k/Lib: http/cookies.py test/test_http_cookies.py

senthil.kumaran python-checkins at python.org
Thu Apr 2 05:02:03 CEST 2009


Author: senthil.kumaran
Date: Thu Apr  2 05:02:03 2009
New Revision: 71030

Log:
Fixing the issue4860. Escaping the embedded '"' in the js_output method of Morsel class.



Modified:
   python/branches/py3k/Lib/http/cookies.py
   python/branches/py3k/Lib/test/test_http_cookies.py

Modified: python/branches/py3k/Lib/http/cookies.py
==============================================================================
--- python/branches/py3k/Lib/http/cookies.py	(original)
+++ python/branches/py3k/Lib/http/cookies.py	Thu Apr  2 05:02:03 2009
@@ -392,7 +392,7 @@
         document.cookie = \"%s\";
         // end hiding -->
         </script>
-        """ % ( self.OutputString(attrs), )
+        """ % ( self.OutputString(attrs).replace('"',r'\"'))
     # end js_output()
 
     def OutputString(self, attrs=None):

Modified: python/branches/py3k/Lib/test/test_http_cookies.py
==============================================================================
--- python/branches/py3k/Lib/test/test_http_cookies.py	(original)
+++ python/branches/py3k/Lib/test/test_http_cookies.py	Thu Apr  2 05:02:03 2009
@@ -50,17 +50,17 @@
 
         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>
         """)


More information about the Python-checkins mailing list