Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.1.X] Fixed #12898: Reverted a change that assumed the file system …

…encoding was utf8, and changed a test to demonstrate how that assumption corrupted uploaded non-ASCII file names on systems that don't use utf8 as their file system encoding (Windows for one, specifically). Thanks for the report to vrehak.

r12661 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12662 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c6e662cd6e84203ca0a5328035d72c6c83f9bae9 1 parent b50b3cf
@kmtracey kmtracey authored
View
4 django/core/files/storage.py
@@ -6,7 +6,7 @@
from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
from django.core.files import locks, File
from django.core.files.move import file_move_safe
-from django.utils.encoding import force_unicode, smart_str
+from django.utils.encoding import force_unicode
from django.utils.functional import LazyObject
from django.utils.importlib import import_module
from django.utils.text import get_valid_filename
@@ -212,7 +212,7 @@ def path(self, name):
path = safe_join(self.location, name)
except ValueError:
raise SuspiciousOperation("Attempted access to '%s' denied." % name)
- return smart_str(os.path.normpath(path))
+ return os.path.normpath(path)
def size(self, name):
return os.path.getsize(self.path(name))
View
11 tests/regressiontests/file_uploads/views.py
@@ -2,7 +2,7 @@
from django.core.files.uploadedfile import UploadedFile
from django.http import HttpResponse, HttpResponseServerError
from django.utils import simplejson
-from models import FileModel
+from models import FileModel, UPLOAD_TO
from uploadhandler import QuotaUploadHandler, ErroringUploadHandler
from django.utils.hashcompat import sha_constructor
from tests import UNICODE_FILENAME
@@ -18,7 +18,7 @@ def file_upload_view(request):
# 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'].name) != '':
- return HttpResponseServerError()
+ return HttpResponseServerError()
return HttpResponse('')
else:
return HttpResponseServerError()
@@ -62,7 +62,8 @@ def file_upload_unicode_name(request):
# through file save.
uni_named_file = request.FILES['file_unicode']
obj = FileModel.objects.create(testfile=uni_named_file)
- if not obj.testfile.name.endswith(uni_named_file.name):
+ full_name = u'%s/%s' % (UPLOAD_TO, uni_named_file.name)
+ if not os.path.exists(full_name):
response = HttpResponseServerError()
# Cleanup the object with its exotic file name immediately.
@@ -82,14 +83,14 @@ def file_upload_echo(request):
"""
r = dict([(k, f.name) for k, f in request.FILES.items()])
return HttpResponse(simplejson.dumps(r))
-
+
def file_upload_quota(request):
"""
Dynamically add in an upload handler.
"""
request.upload_handlers.insert(0, QuotaUploadHandler())
return file_upload_echo(request)
-
+
def file_upload_quota_broken(request):
"""
You can't change handlers after reading FILES; this view shouldn't work.

0 comments on commit c6e662c

Please sign in to comment.
Something went wrong with that request. Please try again.