Fixed #11030: 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.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12661 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
125c748cf6
commit
600aa6679e
|
@ -7,7 +7,7 @@ from django.conf import settings
|
||||||
from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
|
from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
|
||||||
from django.core.files import locks, File
|
from django.core.files import locks, File
|
||||||
from django.core.files.move import file_move_safe
|
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.functional import LazyObject
|
||||||
from django.utils.importlib import import_module
|
from django.utils.importlib import import_module
|
||||||
from django.utils.text import get_valid_filename
|
from django.utils.text import get_valid_filename
|
||||||
|
@ -210,7 +210,7 @@ class FileSystemStorage(Storage):
|
||||||
path = safe_join(self.location, name)
|
path = safe_join(self.location, name)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise SuspiciousOperation("Attempted access to '%s' denied." % name)
|
raise SuspiciousOperation("Attempted access to '%s' denied." % name)
|
||||||
return smart_str(os.path.normpath(path))
|
return os.path.normpath(path)
|
||||||
|
|
||||||
def size(self, name):
|
def size(self, name):
|
||||||
return os.path.getsize(self.path(name))
|
return os.path.getsize(self.path(name))
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
from django.core.files.uploadedfile import UploadedFile
|
from django.core.files.uploadedfile import UploadedFile
|
||||||
from django.http import HttpResponse, HttpResponseServerError
|
from django.http import HttpResponse, HttpResponseServerError
|
||||||
from django.utils import simplejson
|
from django.utils import simplejson
|
||||||
from models import FileModel
|
from models import FileModel, UPLOAD_TO
|
||||||
from uploadhandler import QuotaUploadHandler, ErroringUploadHandler
|
from uploadhandler import QuotaUploadHandler, ErroringUploadHandler
|
||||||
from django.utils.hashcompat import sha_constructor
|
from django.utils.hashcompat import sha_constructor
|
||||||
from tests import UNICODE_FILENAME
|
from tests import UNICODE_FILENAME
|
||||||
|
@ -62,7 +62,8 @@ def file_upload_unicode_name(request):
|
||||||
# through file save.
|
# through file save.
|
||||||
uni_named_file = request.FILES['file_unicode']
|
uni_named_file = request.FILES['file_unicode']
|
||||||
obj = FileModel.objects.create(testfile=uni_named_file)
|
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()
|
response = HttpResponseServerError()
|
||||||
|
|
||||||
# Cleanup the object with its exotic file name immediately.
|
# Cleanup the object with its exotic file name immediately.
|
||||||
|
|
Loading…
Reference in New Issue