]> git.openstreetmap.org Git - osqa.git/commitdiff
Fixes OSQA-142, spaces in uploaded image names = FAIL.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 15 Jul 2010 10:47:40 +0000 (10:47 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 15 Jul 2010 10:47:40 +0000 (10:47 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@530 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/views/writers.py

index c9b005b39f3d3df711d3e237d8a34ba228417d65..74708d651b685dd310350f0042423fae10c63c0f 100644 (file)
@@ -37,13 +37,16 @@ def upload(request):#ajax upload file to a question or answer
             raise UploadPermissionNotAuthorized()
 
         # check file type
-        file_name_suffix = os.path.splitext(f.name)[1].lower()
+        try:
+            file_name_suffix = os.path.splitext(f.name)[1].lower()
+        except KeyError:
+            raise FileTypeNotAllow()
 
         if not file_name_suffix in ('.jpg', '.jpeg', '.gif', '.png', '.bmp', '.tiff', '.ico'):
             raise FileTypeNotAllow()
 
         storage = FileSystemStorage(str(settings.UPFILES_FOLDER), str(settings.UPFILES_ALIAS))
-        new_file_name = storage.save(f.name, f)
+        new_file_name = storage.save("_".join(f.name.split()), f)
         # check file size
         # byte
         size = storage.size(new_file_name)