carlxaeron / django-rosetta

Automatically exported from code.google.com/p/django-rosetta
MIT License
0 stars 0 forks source link

File is read only - when user.first_name or user.last_name contains unicode characters. #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create user with last_name containing non-ascii characters (for 
example "Čermák")
2. Try to save your translation
3. Rosetta switches to read-only mode, even if file is writeable.

Cause:
Line 78 in rosetta/views.py raises UnicodeDecodeError:
rosetta_i18n_pofile.metadata['Last-Translator'] = str("%s %s 
<%s>" %(request.user.first_name,request.user.last_name,request.user.email)) ,

but is caught by generic except on line 81. (I personally believe generic 
excepts are not a good idea.)

Original issue reported on code.google.com by x00...@gmail.com on 12 Jun 2008 at 10:55

GoogleCodeExporter commented 8 years ago
fixed in [29]

I can't really reproduce this bug: even when using non-ascii the Po file is 
properly
saved. In themeantime this should be a quickfix.

Original comment by mbonetti on 17 Jun 2008 at 9:18

GoogleCodeExporter commented 8 years ago
This is not fixed. Using a unicode string for formatting doesn't fix the error, 
or
change anything at all. In any operations involving str and unicode, all str are
decoded into unicode before hand, so the change made NO difference. You get an 
error
when trying to take this unicode string and encoding it into ASCII, which you 
do by
passing it to str() without specifying any other encoding, which is never a good
idea. This seems especially dangerous in an app designed to work with multiple
languages, and thus more likely to be used by people with non-English 
characters in
their name.

The code in question seems to be OK just ditching the meta data here if there 
is a
problem, but it doesn't expect a UnicodeEncodeError, but it probably should. 
I've
made that change locally to fix our problems.

Original comment by ironfro...@gmail.com on 4 Jun 2009 at 4:30