Code

Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#10687 closed (fixed)

request parsing breaks if upload_handlers is empty

Reported by: rfk Owned by: mitsuhiko
Component: File uploads/storage Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If request.upload_handlers is empty, attempts to use MultiPartParser will fail with "TypeError: 'long' object is not iterable". This is caused by the use of min() to calculate the parser chunk size; if upload_handlers is empty then min() is called with a single argument, which it tries to interpret as an iterable.

The attached patch avoids this error and does what I think is the most sensible thing - any file uploads get discarded, but other POST variables are parsed correctly. If this is not desired, perhaps its worth checking for an empty upload_handlers and providing a better error message?

Attachments (1)

multipartparser.py.diff (747 bytes) - added by rfk 5 years ago.

Download all attachments as: .zip

Change History (9)

Changed 5 years ago by rfk

comment:1 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 5 years ago by jacob

Needs a test.

comment:3 Changed 5 years ago by arthurk

  • Owner changed from nobody to arthurk

comment:4 Changed 5 years ago by mitsuhiko

  • Owner changed from arthurk to mitsuhiko

comment:5 Changed 5 years ago by mitsuhiko

comment:6 Changed 5 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

(In [10723]) Fixed #10687: fixed request parsing when upload_handlers is empty. Thanks, Armin Ronacher.

comment:7 Changed 5 years ago by jacob

(In [10765]) [1.0.X] Fixed #10687: fixed request parsing when upload_handlers is empty. Thanks, Armin Ronacher. Backport of [10723] from trunk.

comment:8 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.