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
2a91ce89
Commit
2a91ce89
authored
Jul 25, 2010
by
Gregory P. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes issue #3704: cookielib was not properly handling URLs with a / in the
parameters.
parent
137e0b12
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
18 deletions
+30
-18
Lib/cookielib.py
Lib/cookielib.py
+6
-11
Lib/test/test_cookielib.py
Lib/test/test_cookielib.py
+21
-7
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/cookielib.py
View file @
2a91ce89
...
...
@@ -607,19 +607,14 @@ def eff_request_host(request):
return req_host, erhn
def request_path(request):
"""
request
-
URI
,
as
defined
by
RFC
2965.
"""
"""
Path
component
of
request
-
URI
,
as
defined
by
RFC
2965.
"""
url = request.get_full_url()
#scheme, netloc, path, parameters, query, frag = urlparse.urlparse(url)
#req_path = escape_path("".join(urlparse.urlparse(url)[2:]))
path, parameters, query, frag = urlparse.urlparse(url)[2:]
if parameters:
path = "%s;%s" % (path, parameters)
path = escape_path(path)
req_path = urlparse.urlunparse(("", "", path, "", query, frag))
if not req_path.startswith("/"):
parts = urlparse.urlsplit(url)
path = escape_path(parts.path)
if not path.startswith("/"):
# fix bad RFC 2396 absoluteURI
req_path = "/"+req_
path
return
req_
path
path = "/" +
path
return path
def request_port(request):
host = request.get_host()
...
...
Lib/test/test_cookielib.py
View file @
2a91ce89
# -*- coding: latin-1 -*-
"""Tests for cookielib.py."""
import
re
,
os
,
time
import
cookielib
import
os
import
re
import
time
from
unittest
import
TestCase
from
test
import
test_support
class
DateTimeTests
(
TestCase
):
def
test_time2isoz
(
self
):
...
...
@@ -563,6 +568,16 @@ class CookieTests(TestCase):
interact_netscape
(
c
,
"http://www.acme.com/blah/rhubarb/"
,
'eggs="bar"'
)
self
.
assertIn
(
"/blah/rhubarb"
,
c
.
_cookies
[
"www.acme.com"
])
def
test_default_path_with_query
(
self
):
cj
=
cookielib
.
CookieJar
()
uri
=
"http://example.com/?spam/eggs"
value
=
'eggs="bar"'
interact_netscape
(
cj
,
uri
,
value
)
# default path does not include query, so is "/", not "/?spam"
self
.
assertIn
(
"/"
,
cj
.
_cookies
[
"example.com"
])
# cookie is sent back to the same URI
self
.
assertEquals
(
interact_netscape
(
cj
,
uri
),
value
)
def
test_escape_path
(
self
):
from
cookielib
import
escape_path
cases
=
[
...
...
@@ -591,15 +606,14 @@ class CookieTests(TestCase):
from
urllib2
import
Request
from
cookielib
import
request_path
# with parameters
req
=
Request
(
"http://www.example.com/rheum/rhaponicum;"
"foo=bar;sing=song?apples=pears&spam=eggs#ni"
)
self
.
assertEquals
(
request_path
(
req
),
"/rheum/rhaponicum;"
req
=
Request
(
"http://www.example.com/rheum/rhaponticum;"
"foo=bar;sing=song?apples=pears&spam=eggs#ni"
)
self
.
assertEquals
(
request_path
(
req
),
"/rheum/rhaponticum;foo=bar;sing=song"
)
# without parameters
req
=
Request
(
"http://www.example.com/rheum/rhaponicum?"
"apples=pears&spam=eggs#ni"
)
self
.
assertEquals
(
request_path
(
req
),
"/rheum/rhaponicum?"
req
=
Request
(
"http://www.example.com/rheum/rhaponticum?"
"apples=pears&spam=eggs#ni"
)
self
.
assertEquals
(
request_path
(
req
),
"/rheum/rhaponticum"
)
# missing final slash
req
=
Request
(
"http://www.example.com"
)
self
.
assertEquals
(
request_path
(
req
),
"/"
)
...
...
Misc/NEWS
View file @
2a91ce89
...
...
@@ -18,6 +18,9 @@ Core and Builtins
Library
-------
- Issue #3704: cookielib was not properly handling URLs with a / in the
parameters.
- Issue #9032: XML-RPC client retries the request on EPIPE error. The EPIPE
error occurs when the server closes the socket and the client sends a big
XML-RPC request.
...
...
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