-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-34226: fix cgi.parse_multipart without content_length #8530
bpo-34226: fix cgi.parse_multipart without content_length #8530
Conversation
Lib/cgi.py
Outdated
@@ -717,7 +720,7 @@ def read_lines_to_outerboundary(self): | |||
last_line_lfend = True | |||
_read = 0 | |||
while 1: | |||
if _read >= self.limit: | |||
if self.limit >= 0 and _read >= self.limit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, simplify this to:
if 0 <= self.limit <= _read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks!
6275f1a
to
1e085da
Compare
Thanks a lot for this PR! Here are my two cents:
|
This looks good - we just need a NEWS entry. Click on "Details" next to the failed check for info on how to install and use blurb. (The title of this PR - properly captialised - will be a fine entry, and it can go in the "Library" category.) |
Should I backport to python 3.7? |
Normally backporting will be carried out automatically by nice bots after the PR for master is merged :)
(From https://devguide.python.org/committing/#backporting-changes-to-an-older-version) |
@@ -0,0 +1 @@ | |||
Fix cgi.parse_multipart without content_length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use formatting for cgi.parse_multipart:
cgi.parse_multipart -> cgi.parse_multipart
.
Also, add "Patch by Roger Duran" at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fixed
7243923
to
bd4f196
Compare
Lib/test/test_cgi.py
Outdated
@@ -129,6 +129,20 @@ def test_parse_multipart(self): | |||
'file': [b'Testing 123.\n'], 'title': ['']} | |||
self.assertEqual(result, expected) | |||
|
|||
def test_parse_multipart_without_content_legth(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, here's a typo => test_parse_multipart_without_content_legth should be test_parse_multipart_without_content_length (missing "n")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!, fixed
bd4f196
to
68e9502
Compare
@pablogsal @zooba Is there anything to do for this PR? As per PEP 537:
I guess 3.7.1 is coming soon. I hope this PR can get merged before that. |
The updated PEP 537 states that 3.7.1rc1 is coming the next week
Can this patch be reviewed and merged before that? |
Hi, just notice that this patch it's not yet merged, is there any change to be done? |
If you are waiting this PR as me, temporary solution |
Hey, this patch is still not merged. What is missing? (This is preventing me from upgrading an app to 3.7.) Also, the workaround |
Also add a reference to python/cpython#8530
Also add a reference to python/cpython#8530
@Roger Could you please resolve conflicts? |
In Python 3.7 the behavior of parse_multipart changed requiring CONTENT-LENGTH header, this fix remove this header as required and fix FieldStorage read_lines_to_outerboundary, by not using limit when it's negative, since by default it's -1 if not content-length and keeps substracting what was read from the file object. Also added a test case for this problem.
sure |
68e9502
to
1330f8c
Compare
I like this change. It looks like in #991 while concentrating on encoding, I missed to notice that the variable being looked for was This change will address that regression introduced in 3.7. I will merge this and set the label to backport to 3.7
|
Thanks @Roger for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8, 3.9. |
GH-20890 is a backport of this pull request to the 3.9 branch. |
) In Python 3.7 the behavior of parse_multipart changed requiring CONTENT-LENGTH header, this fix remove this header as required and fix FieldStorage read_lines_to_outerboundary, by not using limit when it's negative, since by default it's -1 if not content-length and keeps substracting what was read from the file object. Also added a test case for this problem. (cherry picked from commit d8cf351) Co-authored-by: roger <rogerduran@gmail.com>
GH-20891 is a backport of this pull request to the 3.8 branch. |
) In Python 3.7 the behavior of parse_multipart changed requiring CONTENT-LENGTH header, this fix remove this header as required and fix FieldStorage read_lines_to_outerboundary, by not using limit when it's negative, since by default it's -1 if not content-length and keeps substracting what was read from the file object. Also added a test case for this problem. (cherry picked from commit d8cf351) Co-authored-by: roger <rogerduran@gmail.com>
GH-20892 is a backport of this pull request to the 3.7 branch. |
) In Python 3.7 the behavior of parse_multipart changed requiring CONTENT-LENGTH header, this fix remove this header as required and fix FieldStorage read_lines_to_outerboundary, by not using limit when it's negative, since by default it's -1 if not content-length and keeps substracting what was read from the file object. Also added a test case for this problem. (cherry picked from commit d8cf351) Co-authored-by: roger <rogerduran@gmail.com>
) (GH-20892) In Python 3.7 the behavior of parse_multipart changed requiring CONTENT-LENGTH header, this fix remove this header as required and fix FieldStorage read_lines_to_outerboundary, by not using limit when it's negative, since by default it's -1 if not content-length and keeps substracting what was read from the file object. Also added a test case for this problem. (cherry picked from commit d8cf351) Co-authored-by: roger <rogerduran@gmail.com> Automerge-Triggered-By: @ned-deily
In Python 3.7 the behavior of parse_multipart changed requiring CONTENT-LENGTH header, this fix remove this header as required and fix FieldStorage read_lines_to_outerboundary, by not using limit when it's negative, since by default it's -1 if not content-length and keeps substracting what was read from the file object. Also added a test case for this problem. (cherry picked from commit d8cf351) Co-authored-by: roger <rogerduran@gmail.com>
In Python 3.7 the behavior of parse_multipart changed requiring CONTENT-LENGTH header, this fix remove this header as required and fix FieldStorage read_lines_to_outerboundary, by not using limit when it's negative, since by default it's -1 if not content-length and keeps substracting what was read from the file object. Also added a test case for this problem. (cherry picked from commit d8cf351) Co-authored-by: roger <rogerduran@gmail.com>
) In Python 3.7 the behavior of parse_multipart changed requiring CONTENT-LENGTH header, this fix remove this header as required and fix FieldStorage read_lines_to_outerboundary, by not using limit when it's negative, since by default it's -1 if not content-length and keeps substracting what was read from the file object. Also added a test case for this problem.
In Python 3.7 the behavior of parse_multipart changed requiring CONTENT-LENGTH
header, this fix remove this header as required and fix FieldStorage
read_lines_to_outerboundary, by not using limit when it's negative,
since by default it's -1 if not content-length and keeps substracting what
was read from the file object.
Also added a test case for this problem.
https://bugs.python.org/issue34226
Automerge-Triggered-By: @orsenthil