#11030: File uploads break on non english filesystem encoding
-------------------------------------------+--------------------------------
          Reporter:  Honza_Kral            |         Owner:  nobody            
            Status:  reopened              |     Milestone:                    
         Component:  File uploads/storage  |       Version:  1.2               
        Resolution:                        |      Keywords:  file path encoding
             Stage:  Unreviewed            |     Has_patch:  1                 
        Needs_docs:  0                     |   Needs_tests:  0                 
Needs_better_patch:  0                     |  
-------------------------------------------+--------------------------------
Changes (by edevil):

  * status:  closed => reopened
  * version:  SVN => 1.2
  * resolution:  fixed =>

Comment:

 This change broke my code when upgrading from 1.1.1 to 1.2.1, and this was
 not listed in the documentation…

 If I upload a file with the name "André.jpg" these are the different
 results for django.core.file.FileSystemStorage.path():

 input - '/servers/staging/sapoopenid/media'
 u'avtr/4791526d60e0ce89ddc5e668c4aa2bb2de08fbc4/Andr\xe9.jpg'

 1.1.1 -
 
'/servers/staging/sapoopenid/media/avtr/4791526d60e0ce89ddc5e668c4aa2bb2de08fbc4/Andr\xc3\xa9.jpg'
 1.2.1 -
 
u'/servers/staging/sapoopenid/media/avtr/4791526d60e0ce89ddc5e668c4aa2bb2de08fbc4/Andr\xe9.jpg'

 Then then os.path.exists() is called on this:

 1.1.1
 >>>
 
os.path.exists('/servers/staging/sapoopenid/media/avtr/4791526d60e0ce89ddc5e668c4aa2bb2de08fbc4/Andr\xc3\xa9.jpg')
 True

 1.2.1
 >>>
 
os.path.exists(u'/servers/staging/sapoopenid/media/avtr/4791526d60e0ce89ddc5e668c4aa2bb2de08fbc4/Andr\xe9.jpg')
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/servers/python/lib/python2.6/genericpath.py", line 18, in exists
     st = os.stat(path)
 UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
 position 84: ordinal not in range(128)

 This causes all sorts of trouble. The storage can't even delete files with
 names like these because exists() is called on them...

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11030#comment:4>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to