Bug 628858 - Upload of [ascii].xpi fails

with "We were unable to connect to the server" in FF 4.0b10
This commit is contained in:
Gregory Koberger 2011-01-26 12:54:59 -08:00
Родитель 42955b2fd6
Коммит d33bbfb01b
3 изменённых файлов: 21 добавлений и 0 удалений

Просмотреть файл

@ -3351,6 +3351,13 @@ class TestUpload(files.tests.UploadTest):
user = UserProfile.objects.get(email='regular@mozilla.com')
eq_(FileUpload.objects.get().user, user)
def test_fileupload_ascii_post(self):
data = open(os.path.join(settings.ROOT, 'apps', 'files', 'fixtures',
'files', u'jétpack.xpi'))
r = self.client.post(self.url, {'upload': data})
# If this is broke, we'll get a traceback.
eq_(r.status_code, 302)
@attr('validator')
def test_fileupload_validation(self):
self.post()

Просмотреть файл

@ -273,6 +273,7 @@ class FileUpload(amo.models.ModelBase):
@classmethod
def from_post(cls, chunks, filename, size):
filename = smart_str(filename)
loc = path.path(settings.ADDONS_PATH) / 'temp' / uuid.uuid4().hex
if not loc.dirname().exists():
loc.dirname().makedirs()

Просмотреть файл

@ -336,6 +336,19 @@ class TestFileUpload(UploadTest):
f.save()
assert not f.valid
def test_ascii_names(self):
fu = FileUpload.from_post('', u'jétpack.xpi', 0)
assert 'xpi' in fu.name
fu = FileUpload.from_post('', u'мозила_србија-0.11-fx.xpi', 0)
assert 'xpi' in fu.name
fu = FileUpload.from_post('', u'フォクすけといっしょ.xpi', 0)
assert 'xpi' in fu.name
fu = FileUpload.from_post('', u'\u05d0\u05d5\u05e1\u05e3.xpi', 0)
assert 'xpi' in fu.name
class TestFileFromUpload(UploadTest):
fixtures = ['base/apps']