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
d5a2377c
Commit
d5a2377c
authored
Apr 23, 2018
by
Berker Peksag
Committed by
GitHub
Apr 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-991266: Fix quoting of Comment attribute of SimpleCookie (GH-6555)
parent
b81ca28b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
+13
-0
Lib/http/cookies.py
Lib/http/cookies.py
+2
-0
Lib/test/test_http_cookies.py
Lib/test/test_http_cookies.py
+10
-0
Misc/NEWS.d/next/Library/2018-04-21-00-24-08.bpo-991266.h93TP_.rst
....d/next/Library/2018-04-21-00-24-08.bpo-991266.h93TP_.rst
+1
-0
No files found.
Lib/http/cookies.py
View file @
d5a2377c
...
...
@@ -408,6 +408,8 @@ class Morsel(dict):
append
(
"%s=%s"
%
(
self
.
_reserved
[
key
],
_getdate
(
value
)))
elif
key
==
"max-age"
and
isinstance
(
value
,
int
):
append
(
"%s=%d"
%
(
self
.
_reserved
[
key
],
value
))
elif
key
==
"comment"
and
isinstance
(
value
,
str
):
append
(
"%s=%s"
%
(
self
.
_reserved
[
key
],
_quote
(
value
)))
elif
key
in
self
.
_flags
:
if
value
:
append
(
str
(
self
.
_reserved
[
key
]))
...
...
Lib/test/test_http_cookies.py
View file @
d5a2377c
...
...
@@ -220,6 +220,16 @@ class CookieTests(unittest.TestCase):
with
self
.
assertRaises
(
cookies
.
CookieError
):
C
.
load
(
rawdata
)
def
test_comment_quoting
(
self
):
c
=
cookies
.
SimpleCookie
()
c
[
'foo'
]
=
'
\
N{COPYRIGHT SIGN}
'
self
.
assertEqual
(
str
(
c
[
'foo'
]),
'Set-Cookie: foo="
\
\
251"'
)
c
[
'foo'
][
'comment'
]
=
'comment
\
N{COPYRIGHT SIGN}
'
self
.
assertEqual
(
str
(
c
[
'foo'
]),
'Set-Cookie: foo="
\
\
251"; Comment="comment
\
\
251"'
)
class
MorselTests
(
unittest
.
TestCase
):
"""Tests for the Morsel object."""
...
...
Misc/NEWS.d/next/Library/2018-04-21-00-24-08.bpo-991266.h93TP_.rst
0 → 100644
View file @
d5a2377c
Fix quoting of the ``Comment`` attribute of :class:`http.cookies.SimpleCookie`.
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