Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d504f20e
Commit
d504f20e
authored
May 23, 2015
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Plain Diff
merge 3.2 (#22931)
parents
deff2b76
9bd476ea
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
Lib/http/cookies.py
Lib/http/cookies.py
+4
-3
Lib/test/test_http_cookies.py
Lib/test/test_http_cookies.py
+13
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/http/cookies.py
View file @
d504f20e
...
@@ -428,12 +428,13 @@ class Morsel(dict):
...
@@ -428,12 +428,13 @@ class Morsel(dict):
# result, the parsing rules here are less strict.
# result, the parsing rules here are less strict.
#
#
_LegalCharsPatt
=
r"[\
w
\d!#%&'~_`><@,:/\
$
\*\
+
\-\
.
\^\
|
\)\
(
\?\
}
\{\
=]
"
_LegalKeyChars
=
r"\
w
\d!#%&'~_`><@,:/\
$
\*\
+
\-\
.
\^\
|
\)\
(
\?\
}
\{\
=
"
_LegalValueChars = _LegalKeyChars + '\
[
\]'
_CookiePattern = re.compile(r"""
_CookiePattern = re.compile(r"""
(?x) # This is a verbose pattern
(?x) # This is a verbose pattern
\
s* # Op
tional whitespace at start of cookie
\
s* # Op
tional whitespace at start of cookie
(?P<key> # Start of group 'key'
(?P<key> # Start of group 'key'
""" + _LegalCharsPatt + r"""
+? # Any word of at least one letter
[""" + _LegalKeyChars + r"""]
+? # Any word of at least one letter
) # End of group 'key'
) # End of group 'key'
( # Optional group: there may not be a value.
( # Optional group: there may not be a value.
\
s*=
\s* # Equal Sign
\
s*=
\s* # Equal Sign
...
@@ -442,7 +443,7 @@ _CookiePattern = re.compile(r"""
...
@@ -442,7 +443,7 @@ _CookiePattern = re.compile(r"""
|
# or
|
# or
\
w
{
3
},
\
s
[
\
w
\
d
\
s
-
]{
9
,
11
}
\
s
[
\
d
:]{
8
}
\
sGMT
# Special case for "expires" attr
\
w
{
3
},
\
s
[
\
w
\
d
\
s
-
]{
9
,
11
}
\
s
[
\
d
:]{
8
}
\
sGMT
# Special case for "expires" attr
|
# or
|
# or
""" + _LegalCharsPatt + r"""
*
# Any word or empty string
[
""" + _LegalValueChars + r"""
]
*
# Any word or empty string
)
# End of group 'val'
)
# End of group 'val'
)
?
# End of optional value group
)
?
# End of optional value group
\
s
*
# Any number of spaces.
\
s
*
# Any number of spaces.
...
...
Lib/test/test_http_cookies.py
View file @
d504f20e
...
@@ -43,6 +43,19 @@ class CookieTests(unittest.TestCase):
...
@@ -43,6 +43,19 @@ class CookieTests(unittest.TestCase):
'repr'
:
"<SimpleCookie: key:term='value:term'>"
,
'repr'
:
"<SimpleCookie: key:term='value:term'>"
,
'output'
:
'Set-Cookie: key:term=value:term'
},
'output'
:
'Set-Cookie: key:term=value:term'
},
# issue22931 - Adding '[' and ']' as valid characters in cookie
# values as defined in RFC 6265
{
'data'
:
'a=b; c=[; d=r; f=h'
,
'dict'
:
{
'a'
:
'b'
,
'c'
:
'['
,
'd'
:
'r'
,
'f'
:
'h'
},
'repr'
:
"<SimpleCookie: a='b' c='[' d='r' f='h'>"
,
'output'
:
'
\
n
'
.
join
((
'Set-Cookie: a=b'
,
'Set-Cookie: c=['
,
'Set-Cookie: d=r'
,
'Set-Cookie: f=h'
))
}
]
]
for
case
in
cases
:
for
case
in
cases
:
...
...
Misc/NEWS
View file @
d504f20e
...
@@ -22,6 +22,8 @@ Core and Builtins
...
@@ -22,6 +22,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #22931: Allow '
[
' and '
]
' in cookie values.
- Issue #24094: Fix possible crash in json.encode with poorly behaved dict
- Issue #24094: Fix possible crash in json.encode with poorly behaved dict
subclasses.
subclasses.
...
...
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