mitsuhiko/werkzeug — pull request #125 by DataBeaver (2011-10-13 20:09:37+00:00)
Title: Improve uploaded file handling in multipart forms

This patch makes werkzeug's multipart form parser count the length of uploaded files and not put empty unnamed files in the list of files in the form. The counting comes essentially for free since the file content is copied out of the request body anyway. The main benefit of this is that constructs like "if 'somefile' in request.files" work as expected. As a side-effect, the content_length member of files always contains a useful value even if the browser didn't supply it.

There's a remote possibility that if the user uploads an empty file and the browser supplies no filename for it, it will be ignored. However, I don't think much is lost in that case.