[Checkins] SVN: zope.publisher/branches/achapman-lenient-cookie-parsing/src/zope/publisher/ - remove duplicate test
Alex Chapman
achapman at zope.com
Thu Dec 15 23:20:29 UTC 2011
Log message for revision 123822:
- remove duplicate test
- add in check for special '$' behavior.
- coverage of the LenientCookie parser
Changed:
U zope.publisher/branches/achapman-lenient-cookie-parsing/src/zope/publisher/http.py
U zope.publisher/branches/achapman-lenient-cookie-parsing/src/zope/publisher/tests/test_http.py
-=-
Modified: zope.publisher/branches/achapman-lenient-cookie-parsing/src/zope/publisher/http.py
===================================================================
--- zope.publisher/branches/achapman-lenient-cookie-parsing/src/zope/publisher/http.py 2011-12-15 22:25:10 UTC (rev 123821)
+++ zope.publisher/branches/achapman-lenient-cookie-parsing/src/zope/publisher/http.py 2011-12-15 23:20:28 UTC (rev 123822)
@@ -183,7 +183,11 @@
# mechanism as a whole. See RFC 2109.
# (Does anyone care?)
if M:
- M[ K[1:] ] = V
+ try:
+ M[ K[1:] ] = V
+ except Cookie.CookieError:
+ # We don't care.
+ pass
elif K.lower() in Cookie.Morsel._reserved:
if M:
M[ K ] = Cookie._unquote(V)
@@ -191,6 +195,7 @@
rval, cval = self.value_decode(V)
try:
self._BaseCookie__set(K, rval, cval)
+ M = self[K]
except Cookie.CookieError, e:
eventlog.warning(e)
Modified: zope.publisher/branches/achapman-lenient-cookie-parsing/src/zope/publisher/tests/test_http.py
===================================================================
--- zope.publisher/branches/achapman-lenient-cookie-parsing/src/zope/publisher/tests/test_http.py 2011-12-15 22:25:10 UTC (rev 123821)
+++ zope.publisher/branches/achapman-lenient-cookie-parsing/src/zope/publisher/tests/test_http.py 2011-12-15 23:20:28 UTC (rev 123822)
@@ -444,7 +444,7 @@
def testCookies(self):
cookies = {
'HTTP_COOKIE':
- 'foo=bar; path=/; spam="eggs", this="Should be accepted"'
+ 'foo=bar; path=/; spam="eggs", this="Should be fine"; $t="f"'
}
req = self._createRequest(extra_env=cookies)
@@ -454,12 +454,15 @@
self.assertEquals(req.cookies[u'spam'], u'eggs')
self.assertEquals(req[u'spam'], u'eggs')
- self.assertEquals(req.cookies[u'this'], u'Should be accepted')
- self.assertEquals(req[u'this'], u'Should be accepted')
+ self.assertEquals(req.cookies[u'this'], u'Should be fine')
+ self.assertEquals(req[u'this'], u'Should be fine')
# Reserved key
self.failIf(req.cookies.has_key('path'))
+ self.failIf(req.cookies.has_key('t'))
+ self.failIf(req.cookies.has_key('$t'))
+
def testCookieErrorToLog(self):
# Cookies accompanying an invalid one shouldn't be trashed.
cookies = {
@@ -477,9 +480,6 @@
self.failIf(req.cookies.has_key('ldap/OU'))
self.failIf(req.has_key('ldap/OU'))
- # Reserved key
- self.failIf(req.cookies.has_key('path'))
-
def testCookiesUnicode(self):
# Cookie values are assumed to be UTF-8 encoded
cookies = {'HTTP_COOKIE': r'key="\342\230\243";'}
More information about the checkins
mailing list