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
1cd4ff62
Commit
1cd4ff62
authored
Mar 19, 2016
by
Berker Peksag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #26560: Avoid potential ValueError in BaseHandler.start_response
Initial patch by Peter Inglesby.
parent
adcb6545
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
Lib/test/test_wsgiref.py
Lib/test/test_wsgiref.py
+21
-0
Lib/wsgiref/handlers.py
Lib/wsgiref/handlers.py
+1
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_wsgiref.py
View file @
1cd4ff62
...
@@ -166,6 +166,27 @@ class IntegrationTests(TestCase):
...
@@ -166,6 +166,27 @@ class IntegrationTests(TestCase):
" be of type list: <class 'tuple'>"
" be of type list: <class 'tuple'>"
)
)
def
test_status_validation_errors
(
self
):
def
create_bad_app
(
status
):
def
bad_app
(
environ
,
start_response
):
start_response
(
status
,
[(
"Content-Type"
,
"text/plain; charset=utf-8"
)])
return
[
b"Hello, world!"
]
return
bad_app
tests
=
[
(
'200'
,
'AssertionError: Status must be at least 4 characters'
),
(
'20X OK'
,
'AssertionError: Status message must begin w/3-digit code'
),
(
'200OK'
,
'AssertionError: Status message must have a space after code'
),
]
for
status
,
exc_message
in
tests
:
with
self
.
subTest
(
status
=
status
):
out
,
err
=
run_amock
(
create_bad_app
(
status
))
self
.
assertTrue
(
out
.
endswith
(
b"A server error occurred. Please contact the administrator."
))
self
.
assertEqual
(
err
.
splitlines
()[
-
2
],
exc_message
)
def
test_wsgi_input
(
self
):
def
test_wsgi_input
(
self
):
def
bad_app
(
e
,
s
):
def
bad_app
(
e
,
s
):
e
[
"wsgi.input"
].
read
()
e
[
"wsgi.input"
].
read
()
...
...
Lib/wsgiref/handlers.py
View file @
1cd4ff62
...
@@ -226,7 +226,7 @@ class BaseHandler:
...
@@ -226,7 +226,7 @@ class BaseHandler:
self
.
headers
=
self
.
headers_class
(
headers
)
self
.
headers
=
self
.
headers_class
(
headers
)
status
=
self
.
_convert_string_type
(
status
,
"Status"
)
status
=
self
.
_convert_string_type
(
status
,
"Status"
)
assert
len
(
status
)
>=
4
,
"Status must be at least 4 characters"
assert
len
(
status
)
>=
4
,
"Status must be at least 4 characters"
assert
int
(
status
[:
3
]),
"Status message must begin w/3-digit code"
assert
status
[:
3
].
isdigit
(),
"Status message must begin w/3-digit code"
assert
status
[
3
]
==
" "
,
"Status message must have a space after code"
assert
status
[
3
]
==
" "
,
"Status message must have a space after code"
if
__debug__
:
if
__debug__
:
...
...
Misc/NEWS
View file @
1cd4ff62
...
@@ -91,6 +91,9 @@ Core and Builtins
...
@@ -91,6 +91,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #26560: Avoid potential ValueError in BaseHandler.start_response.
Initial patch by Peter Inglesby.
- Issue #26313: ssl.py _load_windows_store_certs fails if windows cert store
- Issue #26313: ssl.py _load_windows_store_certs fails if windows cert store
is empty. Patch by Baji.
is empty. Patch by Baji.
...
...
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