Commit 723d6976 authored by Martijn Pieters's avatar Martijn Pieters

Remove the lock around the cookie parsing code.

The locking here was only ever needed for the old `regex` module that was
originally used for this code, but that was replaced by the thread-safe `re`
some 10 years ago (see r20110, april 2001).
parent 83c9815b
...@@ -50,6 +50,10 @@ Features Added ...@@ -50,6 +50,10 @@ Features Added
Restructuring Restructuring
+++++++++++++ +++++++++++++
- Removed the (very obsolete) thread lock around the cookie parsing code
in HTTPRequest.py; the python `re` module is thread-safe, unlike the
ancient `regex` module that was once used here.
- Removed the special handling of `Set-Cookie` headers in - Removed the special handling of `Set-Cookie` headers in
`HTTPResponse.setHeader`. Use the `setCookie`/`appendCookie`/`expireCookie` `HTTPResponse.setHeader`. Use the `setCookie`/`appendCookie`/`expireCookie`
methods instead, or if low-level control is needed, use `addHeader` instead methods instead, or if low-level control is needed, use `addHeader` instead
......
...@@ -40,7 +40,6 @@ from AccessControl.tainted import TaintedString ...@@ -40,7 +40,6 @@ from AccessControl.tainted import TaintedString
from ZPublisher.BaseRequest import BaseRequest from ZPublisher.BaseRequest import BaseRequest
from ZPublisher.BaseRequest import quote from ZPublisher.BaseRequest import quote
from ZPublisher.Converters import get_converter from ZPublisher.Converters import get_converter
from ZPublisher.maybe_lock import allocate_lock
# Flags # Flags
SEQUENCE = 1 SEQUENCE = 1
...@@ -1649,7 +1648,6 @@ class FileUpload: ...@@ -1649,7 +1648,6 @@ class FileUpload:
return self return self
parse_cookie_lock = allocate_lock()
QPARMRE= re.compile( QPARMRE= re.compile(
'([\x00- ]*([^\x00- ;,="]+)="([^"]*)"([\x00- ]*[;,])?[\x00- ]*)') '([\x00- ]*([^\x00- ;,="]+)="([^"]*)"([\x00- ]*[;,])?[\x00- ]*)')
PARMRE = re.compile( PARMRE = re.compile(
...@@ -1661,16 +1659,11 @@ def parse_cookie(text, ...@@ -1661,16 +1659,11 @@ def parse_cookie(text,
qparmre=QPARMRE, qparmre=QPARMRE,
parmre=PARMRE, parmre=PARMRE,
paramlessre=PARAMLESSRE, paramlessre=PARAMLESSRE,
acquire=parse_cookie_lock.acquire,
release=parse_cookie_lock.release,
): ):
if result is None: if result is None:
result = {} result = {}
acquire()
try:
mo_q = qparmre.match(text) mo_q = qparmre.match(text)
if mo_q: if mo_q:
...@@ -1696,8 +1689,6 @@ def parse_cookie(text, ...@@ -1696,8 +1689,6 @@ def parse_cookie(text,
value = '' value = ''
else: else:
return result return result
finally:
release()
if name not in result: if name not in result:
result[name] = unquote(value) result[name] = unquote(value)
......
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