#15879: multipart/form-data filename="" not handled as file
-------------------------------------+-------------------------------------
     Reporter:  j@…                  |                    Owner:  Hridesh
                                     |  MG
         Type:  Bug                  |                   Status:  assigned
    Component:  File                 |                  Version:  1.3
  uploads/storage                    |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Hridesh MG):

 * needs_tests:  1 => 0
 * owner:  nobody => Hridesh MG
 * status:  new => assigned

Comment:

 Can confirm that this is still reproducible, I've written the following
 test that can be added to `tests/requests_tests.py`

 {{{#!python
     def test_POST_multipart_with_empty_filename(self):
         payload = FakePayload(
             "\r\n".join(
                 [
                     f"--{BOUNDARY}",
                     'Content-Disposition: form-data; name="File";
 filename=""',
                     "Content-Type: application/octet-stream",
                     "",
                     "Framework,ID",
                     "Django,1",
                     "Flask,2",
                     f"--{BOUNDARY}--",
                 ]
             )
         )
         request = WSGIRequest(
             {
                 "REQUEST_METHOD": "POST",
                 "CONTENT_TYPE": MULTIPART_CONTENT,
                 "CONTENT_LENGTH": len(payload),
                 "wsgi.input": payload,
             }
         )
         self.assertEqual(len(request.FILES), 1)
         self.assertIsInstance((request.FILES["File"]),
 InMemoryUploadedFile)


 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/15879#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019575101cec-fedcd951-236d-4921-b093-b16ab0e4fcd8-000000%40eu-central-1.amazonses.com.

Reply via email to