Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
e32b20fe
Commit
e32b20fe
authored
Apr 16, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process "evil" JSON cookies which contain double quotes
Such cookies violate RFC 2965 / 2616. Fixes LP #563229.
parent
63c7bb8e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
doc/CHANGES.rst
doc/CHANGES.rst
+3
-0
src/ZPublisher/HTTPRequest.py
src/ZPublisher/HTTPRequest.py
+1
-1
src/ZPublisher/tests/testHTTPRequest.py
src/ZPublisher/tests/testHTTPRequest.py
+14
-0
No files found.
doc/CHANGES.rst
View file @
e32b20fe
...
...
@@ -11,6 +11,9 @@ http://docs.zope.org/zope2/releases/.
Bugs Fixed
++++++++++
- LP #563229: Process "evil" JSON cookies which contain double quotes in
violation of RFC 2965 / 2616.
- Document ``Products.PluginIndexes.PathIndex.PathIndex.insertEntry`` as
an API for use by subclasses.
...
...
src/ZPublisher/HTTPRequest.py
View file @
e32b20fe
...
...
@@ -1642,7 +1642,7 @@ parse_cookie_lock = allocate_lock()
QPARMRE
=
re
.
compile
(
'([
\
x00
- ]*([^
\
x00
- ;,="]+)="([^"]*)"([
\
x00
- ]*[;,])?[
\
x00
- ]*)'
)
PARMRE
=
re
.
compile
(
'([
\
x00
- ]*([^
\
x00
- ;,="]+)=([^;
,"
]*)([
\
x00
- ]*[;,])?[
\
x00
- ]*)'
)
'([
\
x00
- ]*([^
\
x00
- ;,="]+)=([^;]*)([
\
x00
- ]*[;,])?[
\
x00
- ]*)'
)
PARAMLESSRE
=
re
.
compile
(
'([
\
x00
- ]*([^
\
x00
- ;,="]+)[
\
x00
- ]*[;,][
\
x00
- ]*)'
)
def
parse_cookie
(
text
,
...
...
src/ZPublisher/tests/testHTTPRequest.py
View file @
e32b20fe
...
...
@@ -996,6 +996,20 @@ class HTTPRequestTests(unittest.TestCase):
"HTTPRequest.resolve_url should not emit events"
)
def
test_parses_json_cookies
(
self
):
# https://bugs.launchpad.net/zope2/+bug/563229
# reports cookies in the wild with embedded double quotes (e.g,
# JSON-encoded data structures.
env
=
{
'SERVER_NAME'
:
'testingharnas'
,
'SERVER_PORT'
:
'80'
,
'HTTP_COOKIE'
:
'json={"intkey":123,"stringkey":"blah"}; '
'anothercookie=boring; baz'
}
req
=
self
.
_makeOne
(
environ
=
env
)
self
.
assertEquals
(
req
.
cookies
[
'json'
],
'{"intkey":123,"stringkey":"blah"}'
)
self
.
assertEquals
(
req
.
cookies
[
'anothercookie'
],
'boring'
)
TEST_ENVIRON
=
{
'CONTENT_TYPE'
:
'multipart/form-data; boundary=12345'
,
'REQUEST_METHOD'
:
'POST'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment