Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #7143 -- Modified the test client to better match (most) real b…

…rowser behavior when uploading files. Now, only the file name is sent, rather than the full path. Thanks for the report, cpinto.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 46cd8bb5b6c937969ca281f124307013454f5c15 1 parent d234e92
@freakboy3742 freakboy3742 authored
3  django/test/
@@ -1,5 +1,6 @@
import urllib
import sys
+import os
from cStringIO import StringIO
from django.conf import settings
from django.contrib.auth import authenticate, login
@@ -67,7 +68,7 @@ def encode_multipart(boundary, data):
if isinstance(value, file):
'--' + boundary,
- 'Content-Disposition: form-data; name="%s"; filename="%s"' % (to_str(key), to_str(,
+ 'Content-Disposition: form-data; name="%s"; filename="%s"' % (to_str(key), to_str(os.path.basename(,
'Content-Type: application/octet-stream',
6 tests/regressiontests/test_client_regress/
@@ -1,3 +1,5 @@
+import os
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseServerError
@@ -13,6 +15,10 @@ def file_upload_view(request):
form_data = request.POST.copy()
if isinstance(form_data['file_field'], dict) and isinstance(form_data['name'], unicode):
+ # If a file is posted, the dummy client should only post the file name,
+ # not the full path.
+ if os.path.dirname(form_data['file_field']['filename']) != '':
+ return HttpResponseServerError()
return HttpResponse('')
return HttpResponseServerError()
Please sign in to comment.
Something went wrong with that request. Please try again.