Error uploading avatar with non-ascii filename.

VERIFIED FIXED in 2013-02-07

Status

Participation Infrastructure
Phonebook
VERIFIED FIXED
6 years ago
6 years ago

People

(Reporter: mbrandt, Assigned: giorgos)

Tracking

other
2013-02-07

Details

(Whiteboard: [trackback][prod], URL)

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
Traceback (most recent call last):

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/core/handlers/base.py", line 111, in get_response
   response = callback(request, *callback_args, **callback_kwargs)

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/views/decorators/cache.py", line 88, in _wrapped_view_func
   response = view_func(request, *args, **kwargs)

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/contrib/auth/decorators.py", line 19, in _wrapped_view
   return view_func(request, *args, **kwargs)

 File "/data/www/mozillians.org/mozillians/apps/phonebook/views.py", line 78, in edit_profile
   form.save(request)

 File "/data/www/mozillians.org/mozillians/apps/phonebook/forms.py", line 173, in save
   super(ProfileForm, self).save(request.user)

 File "/data/www/mozillians.org/mozillians/apps/phonebook/forms.py", line 99, in save
   super(forms.ModelForm, self).save()

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/forms/models.py", line 363, in save
   fail_message, commit, construct=False)

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/forms/models.py", line 85, in save_instance
   instance.save()

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/db/models/base.py", line 463, in save
   self.save_base(using=using, force_insert=force_insert, force_update=force_update)

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/db/models/base.py", line 528, in save_base
   values = [(f, None, (raw and getattr(self, f.attname) or f.pre_save(self, False))) for f in non_pks]

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/db/models/fields/files.py", line 253, in pre_save
   file.save(file.name, file, save=False)

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/db/models/fields/files.py", line 90, in save
   self.name = self.storage.save(name, content)

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/core/files/storage.py", line 48, in save
   name = self.get_available_name(name)

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/core/files/storage.py", line 74, in get_available_name
   while self.exists(name):

 File "/data/www/mozillians.org/mozillians/vendor/src/django/django/core/files/storage.py", line 233, in exists
   return os.path.exists(self.path(name))

 File "/usr/lib64/python2.6/genericpath.py", line 18, in exists
   st = os.stat(path)

UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 68: ordinal not in range(128)
Duplicate of this bug: 755798
(Reporter)

Updated

6 years ago
Duplicate of this bug: 764437
(Reporter)

Comment 3

6 years ago
Tracebacks are still occurring on production -- can we get this cleaned up?
Whiteboard: [trackback] → [trackback][prod]
Mozillians fails to e.g. add languages with non-ascii characters like "Französisch" (= "French"). I guess it is covered by this bug because the stacktrace mentions ProfileForm.

Comment 5

6 years ago
Ok will add this to backlog to take a look at.

Comment 6

6 years ago
Assigning to myself to figure out exactly where this occurs and add steps to reproduce.
Assignee: nobody → booboobenny+bugzilla
I believe the traceback refers to saving profile pictures with non latin characters in their filenames.

Comment #4 on the other hand deals with users adding 'languages' under 'skills and groups' which contain non latin characters.

Comment 8

6 years ago
Confirmed 2 issues:

1. Trying to upload an image with non-latin throws error
2. Adding skills or group with non-latin throws error

To me seems like we should allow both.

Giorgos can you think of any technical reason why we would not do this?

If we agree I can create two sep bugs for the above that will block this one.
Flags: needinfo?(giorgos)
Ben:

1. I can think of tech reasons which cause not to work but we can fix a workaround. (e.g. using the sha1 hash of the image as the filename)

2. I believe it's just the javascript used to add the skills and languages. Can be part of the UI/UX re-build.
Flags: needinfo?(giorgos)
Keeping this bug for filename issue, opening another one for group editing.
Assignee: booboobenny+bugzilla → giorgos
Status: NEW → ASSIGNED
Summary: [traceback] Error: UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 68: ordinal not in range(128) → Error uploading avatar with non-ascii filename.

Comment 12

6 years ago
Commits pushed to master at https://github.com/mozilla/mozillians

https://github.com/mozilla/mozillians/commit/1e99a0bc8c75b433ad4fb38b2a4821d55fba1acc
[fix bug 748057] Allow uploads with non-ascii filename.

https://github.com/mozilla/mozillians/commit/8c79d41cb70272e6bbe534849852917e3b99b41e
Merge pull request #380 from glogiotatidis/748057

[fix bug 748057] Allow uploads with non-ascii filename.

Updated

6 years ago
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2013-02-07
(Reporter)

Comment 13

6 years ago
Created attachment 709902 [details]
qa - reopened

Reopening: I'm able to trigger the following traceback with the attached jpg file. This is reproducible on dev and stage.

Traceback (most recent call last):

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/views/decorators/cache.py", line 89, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/contrib/auth/decorators.py", line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)

  File "/data/www/mozillians.allizom.org/mozillians/apps/phonebook/views.py", line 99, in edit_profile
    profile_form.save()

  File "/data/www/mozillians.allizom.org/mozillians/apps/phonebook/forms.py", line 160, in save
    super(BaseProfileForm, self).save()

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/forms/models.py", line 364, in save
    fail_message, commit, construct=False)

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/forms/models.py", line 86, in save_instance
    instance.save()

  File "/data/www/mozillians.allizom.org/mozillians/apps/users/models.py", line 303, in save
    super(UserProfile, self).save(*args, **kwargs)

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/db/models/base.py", line 463, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/db/models/base.py", line 527, in save_base
    values = [(f, None, (raw and getattr(self, f.attname) or f.pre_save(self, False))) for f in non_pks]

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/db/models/fields/files.py", line 249, in pre_save
    file.save(file.name, file, save=False)

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/db/models/fields/files.py", line 86, in save
    self.name = self.storage.save(name, content)

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/core/files/storage.py", line 44, in save
    name = self.get_available_name(name)

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/core/files/storage.py", line 70, in get_available_name
    while self.exists(name):

  File "/data/www/mozillians.allizom.org/mozillians/vendor/src/django/django/core/files/storage.py", line 230, in exists
    return os.path.exists(self.path(name))

  File "/usr/lib64/python2.6/genericpath.py", line 18, in exists
    st = os.stat(path)

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2400' in position 107: ordinal not in range(128)
(Reporter)

Updated

6 years ago
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Matt, can you send me the filename of the file you uploaded?
(Reporter)

Comment 15

6 years ago
(In reply to Giorgos Logiotatidis [:giorgos] from comment #14)
> Matt, can you send me the filename of the file you uploaded?

Sorry about that. I didn't notice the file type got stripped off.

qa_reopened.␀
So you used a non ascii character for the filename extension and not the filename, right?
(Reporter)

Comment 17

6 years ago
(In reply to Giorgos Logiotatidis [:giorgos] from comment #16)
> So you used a non ascii character for the filename extension and not the
> filename, right?

Correct
Haha nice catch then! I've a pull request waiting for review with a fix.

Thanks for the detailed testing ;)

Comment 19

6 years ago
Commits pushed to master at https://github.com/mozilla/mozillians

https://github.com/mozilla/mozillians/commit/c4755ae43083d6de3e63222a28759a7667ee4a82
[bug 748057] Allow image filenames without type extension.

https://github.com/mozilla/mozillians/commit/c2dd21793a3f476bdff39fe871b5fa1fba48912d
Merge pull request #385 from glogiotatidis/748057

[bug 748057] Allow image filenames without type extension.
Status: REOPENED → RESOLVED
Last Resolved: 6 years ago6 years ago
Resolution: --- → FIXED
(Reporter)

Comment 20

6 years ago
QA verified on stage - filenames containing non-ascii characters that are image files are correctly detected and displayed. This included files that have improper extensions.

Example:
image.␀
␀.␀
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.