@@ -618,6 +618,18 @@ def test_control_characters(self):
618618 with self .assertRaises (cookies .CookieError ):
619619 morsel .set ("path" , "val" , c0 )
620620
621+ # .update()
622+ with self .assertRaises (cookies .CookieError ):
623+ morsel .update ({"path" : c0 })
624+ with self .assertRaises (cookies .CookieError ):
625+ morsel .update ({c0 : "val" })
626+
627+ # .__ior__()
628+ with self .assertRaises (cookies .CookieError ):
629+ morsel |= {"path" : c0 }
630+ with self .assertRaises (cookies .CookieError ):
631+ morsel |= {c0 : "val" }
632+
621633 def test_control_characters_output (self ):
622634 # Tests that even if the internals of Morsel are modified
623635 # that a call to .output() has control character safeguards.
@@ -638,6 +650,24 @@ def test_control_characters_output(self):
638650 with self .assertRaises (cookies .CookieError ):
639651 cookie .output ()
640652
653+ # Tests that .js_output() also has control character safeguards.
654+ for c0 in support .control_characters_c0 ():
655+ morsel = cookies .Morsel ()
656+ morsel .set ("key" , "value" , "coded-value" )
657+ morsel ._key = c0 # Override private variable.
658+ cookie = cookies .SimpleCookie ()
659+ cookie ["cookie" ] = morsel
660+ with self .assertRaises (cookies .CookieError ):
661+ cookie .js_output ()
662+
663+ morsel = cookies .Morsel ()
664+ morsel .set ("key" , "value" , "coded-value" )
665+ morsel ._coded_value = c0 # Override private variable.
666+ cookie = cookies .SimpleCookie ()
667+ cookie ["cookie" ] = morsel
668+ with self .assertRaises (cookies .CookieError ):
669+ cookie .js_output ()
670+
641671
642672def load_tests (loader , tests , pattern ):
643673 tests .addTest (doctest .DocTestSuite (cookies ))
0 commit comments