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
a02e18a4
Commit
a02e18a4
authored
Oct 03, 2015
by
Martin Panter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #25232: Fix CGIRequestHandler's splitting of URL query
Patch from Xiang Zhang.
parent
d470527a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
5 deletions
+29
-5
Lib/http/server.py
Lib/http/server.py
+1
-5
Lib/test/test_httpservers.py
Lib/test/test_httpservers.py
+24
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/http/server.py
View file @
a02e18a4
...
...
@@ -1032,11 +1032,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
break
# find an explicit query string, if present.
i
=
rest
.
rfind
(
'?'
)
if
i
>=
0
:
rest
,
query
=
rest
[:
i
],
rest
[
i
+
1
:]
else
:
query
=
''
rest
,
_
,
query
=
rest
.
partition
(
'?'
)
# dissect the part after the directory name into a script name &
# a possible additional path, to be stored in PATH_INFO.
...
...
Lib/test/test_httpservers.py
View file @
a02e18a4
...
...
@@ -366,6 +366,16 @@ print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),
form.getfirst("bacon")))
"""
cgi_file4
=
"""
\
#!%s
import os
print("Content-type: text/html")
print()
print(os.environ["%s"])
"""
@
unittest
.
skipIf
(
hasattr
(
os
,
'geteuid'
)
and
os
.
geteuid
()
==
0
,
"This test can't be run reliably as root (issue #13308)."
)
...
...
@@ -387,6 +397,7 @@ class CGIHTTPServerTestCase(BaseTestCase):
self
.
file1_path
=
None
self
.
file2_path
=
None
self
.
file3_path
=
None
self
.
file4_path
=
None
# The shebang line should be pure ASCII: use symlink if possible.
# See issue #7668.
...
...
@@ -425,6 +436,11 @@ class CGIHTTPServerTestCase(BaseTestCase):
file3
.
write
(
cgi_file1
%
self
.
pythonexe
)
os
.
chmod
(
self
.
file3_path
,
0o777
)
self
.
file4_path
=
os
.
path
.
join
(
self
.
cgi_dir
,
'file4.py'
)
with
open
(
self
.
file4_path
,
'w'
,
encoding
=
'utf-8'
)
as
file4
:
file4
.
write
(
cgi_file4
%
(
self
.
pythonexe
,
'QUERY_STRING'
))
os
.
chmod
(
self
.
file4_path
,
0o777
)
os
.
chdir
(
self
.
parent_dir
)
def
tearDown
(
self
):
...
...
@@ -440,6 +456,8 @@ class CGIHTTPServerTestCase(BaseTestCase):
os
.
remove
(
self
.
file2_path
)
if
self
.
file3_path
:
os
.
remove
(
self
.
file3_path
)
if
self
.
file4_path
:
os
.
remove
(
self
.
file4_path
)
os
.
rmdir
(
self
.
cgi_child_dir
)
os
.
rmdir
(
self
.
cgi_dir
)
os
.
rmdir
(
self
.
parent_dir
)
...
...
@@ -541,6 +559,12 @@ class CGIHTTPServerTestCase(BaseTestCase):
self
.
assertEqual
((
b'Hello World'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
def
test_query_with_multiple_question_mark
(
self
):
res
=
self
.
request
(
'/cgi-bin/file4.py?a=b?c=d'
)
self
.
assertEqual
(
(
b'a=b?c=d'
+
self
.
linesep
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
class
SocketlessRequestHandler
(
SimpleHTTPRequestHandler
):
def
__init__
(
self
):
...
...
Misc/ACKS
View file @
a02e18a4
...
...
@@ -1531,6 +1531,7 @@ Thomas Wouters
Daniel Wozniak
Heiko Wundram
Doug Wyatt
Xiang Zhang
Robert Xiao
Florent Xicluna
Hirokazu Yamamoto
...
...
Misc/NEWS
View file @
a02e18a4
...
...
@@ -90,6 +90,9 @@ Core and Builtins
Library
-------
- Issue #25232: Fix CGIRequestHandler to split the query from the URL at the
first question mark (?) rather than the last. Patch from Xiang Zhang.
- Issue #22958: Constructor and update method of weakref.WeakValueDictionary
now accept the self and the dict keyword arguments.
...
...
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