Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7877a76

Browse files
committed
Patch #655760: add warnings when the unsafe *Cookie classes are instantiated
1 parent ea3fdf4 commit 7877a76

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Lib/Cookie.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
except ImportError:
223223
from pickle import dumps, loads
224224

225-
import re
225+
import re, warnings
226226

227227
__all__ = ["CookieError","BaseCookie","SimpleCookie","SerialCookie",
228228
"SmartCookie","Cookie"]
@@ -682,6 +682,11 @@ class SerialCookie(BaseCookie):
682682
Note: HTTP has a 2k limit on the size of a cookie. This class
683683
does not check for this limit, so be careful!!!
684684
"""
685+
def __init__(self, input=None):
686+
warnings.warn("SerialCookie class is insecure; do not use it",
687+
DeprecationWarning)
688+
BaseCookie.__init__(self, input)
689+
# end __init__
685690
def value_decode(self, val):
686691
# This could raise an exception!
687692
return loads( _unquote(val) ), val
@@ -702,6 +707,11 @@ class SmartCookie(BaseCookie):
702707
Note: HTTP has a 2k limit on the size of a cookie. This class
703708
does not check for this limit, so be careful!!!
704709
"""
710+
def __init__(self, input=None):
711+
warnings.warn("Cookie/SmartCookie class is insecure; do not use it",
712+
DeprecationWarning)
713+
BaseCookie.__init__(self, input)
714+
# end __init__
705715
def value_decode(self, val):
706716
strval = _unquote(val)
707717
try:

0 commit comments

Comments
 (0)