-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-35028: cgi: Fix max_num_fields off by one error #9973
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-35028: cgi: Fix max_num_fields off by one error #9973
Conversation
I figure this shouldn't need a merge entry since there hasn't been a release since #9660. If it does let me know and I'll add one. |
Lib/cgi.py
Outdated
max_num_fields = self.max_num_fields | ||
sub_max_num_fields = self.max_num_fields | ||
if max_num_fields is not None: | ||
sub_max_num_fields -= len(self.list) |
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.
I'm not so happy for maintain two local variables.
How about keep only max_num_fields?
max_num_fields = self.max_num_fields
if max_num_fields is not None:
max_num_fields -= len(self.list)
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.
Oh, github removed my one comment.
[snip]
part = klass(..., max_num_fields)
[snip]
if max_num_fields is not None:
max_num_fields -= 1
if part.list:
max_num_fields -= len(part.list)
if max_num_fields < 0:
raise ValueError('Max number of fields exceeded')
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 idea, that is simpler. I fixed that in a7203c8.
Thanks @matthewbelisle-wf for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
https://bugs.python.org/issue35028 (cherry picked from commit b79b5c0) Co-authored-by: matthewbelisle-wf <[email protected]>
GH-10053 is a backport of this pull request to the 3.7 branch. |
GH-10054 is a backport of this pull request to the 3.6 branch. |
https://bugs.python.org/issue35028 (cherry picked from commit b79b5c0) Co-authored-by: matthewbelisle-wf <[email protected]>
https://bugs.python.org/issue35028 (cherry picked from commit b79b5c0) Co-authored-by: matthewbelisle-wf <[email protected]>
https://bugs.python.org/issue35028 (cherry picked from commit b79b5c0) Co-authored-by: matthewbelisle-wf <[email protected]>
https://bugs.python.org/issue35028