Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
cc261871
Commit
cc261871
authored
Sep 12, 2018
by
tzickel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed negative length in pywsgi's Input read functions for non chunked body
parent
02eb41d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
4 deletions
+57
-4
CHANGES.rst
CHANGES.rst
+1
-1
src/gevent/pywsgi.py
src/gevent/pywsgi.py
+4
-3
src/greentest/test__pywsgi.py
src/greentest/test__pywsgi.py
+52
-0
No files found.
CHANGES.rst
View file @
cc261871
...
...
@@ -9,7 +9,7 @@
- Formatting run info no longer includes ``gevent.local.local``
objects that have no value in the greenlet. See :issue:`1275`.
- Fixed negative length in pywsgi's Input read functions for non chunked body.
1.3.6 (2018-08-17)
==================
...
...
src/gevent/pywsgi.py
View file @
cc261871
...
...
@@ -267,9 +267,6 @@ class Input(object):
if
length
==
0
:
return
b""
if
length
is
not
None
and
length
<
0
:
length
=
None
if
use_readline
:
reader
=
self
.
rfile
.
readline
else
:
...
...
@@ -312,11 +309,15 @@ class Input(object):
return
b''
.
join
(
response
)
def
read
(
self
,
length
=
None
):
if
length
is
not
None
and
length
<
0
:
length
=
None
if
self
.
chunked_input
:
return
self
.
_chunked_read
(
length
)
return
self
.
_do_read
(
length
)
def
readline
(
self
,
size
=
None
):
if
size
is
not
None
and
size
<
0
:
size
=
None
if
self
.
chunked_input
:
return
self
.
_chunked_read
(
size
,
True
)
return
self
.
_do_read
(
size
,
use_readline
=
True
)
...
...
src/greentest/test__pywsgi.py
View file @
cc261871
...
...
@@ -551,6 +551,58 @@ class TestBigChunks(TestChunkedApp):
chunks
=
[
b'a'
*
8192
]
*
3
class
TestNegativeRead
(
TestCase
):
@
staticmethod
def
application
(
env
,
start_response
):
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
)])
if
env
[
'PATH_INFO'
]
==
'/read'
:
data
=
env
[
'wsgi.input'
].
read
(
-
1
)
return
[
data
]
def
test_negative_chunked_read
(
self
):
fd
=
self
.
makefile
()
data
=
(
b'POST /read HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
'
b'Transfer-Encoding: chunked
\
r
\
n
\
r
\
n
'
b'2
\
r
\
n
oh
\
r
\
n
4
\
r
\
n
hai
\
r
\
n
0
\
r
\
n
\
r
\
n
'
)
fd
.
write
(
data
)
read_http
(
fd
,
body
=
'oh hai'
)
def
test_negative_nonchunked_read
(
self
):
fd
=
self
.
makefile
()
data
=
(
b'POST /read HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
'
b'Content-Length: 6
\
r
\
n
\
r
\
n
'
b'oh hai'
)
fd
.
write
(
data
)
read_http
(
fd
,
body
=
'oh hai'
)
class
TestNegativeReadline
(
TestCase
):
validator
=
None
@
staticmethod
def
application
(
env
,
start_response
):
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
)])
if
env
[
'PATH_INFO'
]
==
'/readline'
:
data
=
env
[
'wsgi.input'
].
readline
(
-
1
)
return
[
data
]
def
test_negative_chunked_readline
(
self
):
fd
=
self
.
makefile
()
data
=
(
b'POST /readline HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
'
b'Transfer-Encoding: chunked
\
r
\
n
\
r
\
n
'
b'2
\
r
\
n
oh
\
r
\
n
4
\
r
\
n
hai
\
r
\
n
0
\
r
\
n
\
r
\
n
'
)
fd
.
write
(
data
)
read_http
(
fd
,
body
=
'oh hai'
)
def
test_negative_nonchunked_readline
(
self
):
fd
=
self
.
makefile
()
data
=
(
b'POST /readline HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
'
b'Content-Length: 6
\
r
\
n
\
r
\
n
'
b'oh hai'
)
fd
.
write
(
data
)
read_http
(
fd
,
body
=
'oh hai'
)
class
TestChunkedPost
(
TestCase
):
@
staticmethod
...
...
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