summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2001-08-18 18:22:11 +0000
committerbwarsaw2001-08-18 18:22:11 +0000
commit3f0f43d1c19eb0849f8bbd2e749e57d0b5019ec5 (patch)
tree015f288e84496396efdb0e75fa2e8a27d085454c
parent63dab1ee6eb81bdbbceae6a671779334879f01bd (diff)
downloadmailman-3f0f43d1c19eb0849f8bbd2e749e57d0b5019ec5.tar.gz
mailman-3f0f43d1c19eb0849f8bbd2e749e57d0b5019ec5.tar.zst
mailman-3f0f43d1c19eb0849f8bbd2e749e57d0b5019ec5.zip
Morsel.set(): Add optional argument `strict', defaulting to 1, which
controls whether reserved key checking is done. Cookie.__ParseString(): When calling Morsel.set(), set strict=0 so no reserved key checking will be done. This makes sense because normally, the input data is coming from the web and we should be liberal in what we accept here. E.g. if a browser is setting "Version=1" we shouldn't crap out on the whole cookie just because of that. We /do/ want to be more strict when we're setting individual keys programmatically (but that will never call __ParseString()).
-rw-r--r--misc/Cookie.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/misc/Cookie.py b/misc/Cookie.py
index d2fe81c22..23af3e2f7 100644
--- a/misc/Cookie.py
+++ b/misc/Cookie.py
@@ -4,6 +4,7 @@
####
# Copyright (C) 1998 GTE Internetworking
# Author: Timothy O'Malley <timo@bbn.com>
+# Hacked: Barry Warsaw <barry@zope.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -416,8 +417,8 @@ class Morsel(UserDict):
UserDict.__setitem__(self, K, V)
# end __setitem__
- def set(self, key, val, coded_val):
- if string.lower(key) in self.__reserved_keys:
+ def set(self, key, val, coded_val, strict=1):
+ if strict and string.lower(key) in self.__reserved_keys:
raise CookieError("Attempt to set a reserved key: %s" % key)
self.key = key
self.value = val
@@ -570,7 +571,7 @@ class Cookie(UserDict):
# (Does anyone care?)
else:
M = Morsel()
- M.set(K, apply(self.net_setfunc, (V,)), V)
+ M.set(K, apply(self.net_setfunc, (V,)), V, strict=0)
UserDict.__setitem__(self, K, M)
return
# end __ParseString