Commit 3e2ea79b authored by Senthil Kumaran's avatar Senthil Kumaran

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

parent b868a66c
...@@ -392,7 +392,7 @@ class Morsel(dict): ...@@ -392,7 +392,7 @@ class Morsel(dict):
document.cookie = \"%s\"; document.cookie = \"%s\";
// end hiding --> // end hiding -->
</script> </script>
""" % ( self.OutputString(attrs), ) """ % ( self.OutputString(attrs).replace('"',r'\"'))
# end js_output() # end js_output()
def OutputString(self, attrs=None): def OutputString(self, attrs=None):
......
...@@ -50,17 +50,17 @@ class CookieTests(unittest.TestCase): ...@@ -50,17 +50,17 @@ class CookieTests(unittest.TestCase):
self.assertEqual(C.output(['path']), self.assertEqual(C.output(['path']),
'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme') 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme')
self.assertEqual(C.js_output(), """ self.assertEqual(C.js_output(), r"""
<script type="text/javascript"> <script type="text/javascript">
<!-- begin hiding <!-- begin hiding
document.cookie = "Customer="WILE_E_COYOTE"; Path=/acme; Version=1"; document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1";
// end hiding --> // end hiding -->
</script> </script>
""") """)
self.assertEqual(C.js_output(['path']), """ self.assertEqual(C.js_output(['path']), r"""
<script type="text/javascript"> <script type="text/javascript">
<!-- begin hiding <!-- begin hiding
document.cookie = "Customer="WILE_E_COYOTE"; Path=/acme"; document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme";
// end hiding --> // end hiding -->
</script> </script>
""") """)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment