mediagoblin icon indicating copy to clipboard operation
mediagoblin copied to clipboard

Mediagoblin on Sandstorm crashes any time a user with an accent in their full name uploads a photo

Open aldeka opened this issue 9 years ago • 0 comments

To reproduce:

  • Make a user on sandstorm.io that has an accented character in their full name. Say "Jane Tölva".
  • Make a Mediagoblin grain.
  • Upload a photo to the grain.

You'll get a "YEOWCH" error with the following logs:

Error - <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode characters in position 17-18: ordinal not in range(128) URL: https://6fed0ea39eb58489a359840924405300.oasis.sandstorm.io/u/Karen%20Rustad%20T%C3%83%C2%B6lva/ File '/opt/app/local/lib/python2.7/site-packages/paste/exceptions/errormiddleware.py', line 144 in call app_iter = self.application(environ, sr_checker) File '/opt/app/local/lib/python2.7/site-packages/paste/deploy/config.py', line 291 in call return self.app(environ, start_response) File '/opt/app/mediagoblin/app.py', line 342 in call return self.call_backend(environ, start_response) File '/opt/app/local/lib/python2.7/site-packages/werkzeug/wsgi.py', line 570 in call cleaned_path = cleaned_path.encode(sys.getfilesystemencoding()) UnicodeEncodeError: 'ascii' codec can't encode characters in position 17-18: ordinal not in range(128)

The problem appears to be that Mediagoblin is using HTTP_X_SANDSTORM_USERNAME to generate the "username" for the user in the grain. But this property is the user's full name and can have special characters in it--something that the normal mediagoblin user creation flow prevents. You likely want to use HTTP_X_SANDSTORM_PREFERRED_HANDLE to get a username instead. Either that or make the username field Unicode compatible.

aldeka avatar Feb 24 '16 00:02 aldeka