Accents in user name makes Rhodecode Crash

Issue #701 resolved
Anonymous created an issue

When a username has an accent in his name, Rhodecode crashes in several pages (ChangeLog, Admin Repos, ...)

Here is the stack:

Module rhodecode.controllers.changeset:2 in before Module rhodecode.lib.auth:468 in __wrapper

return func(fargs, fkwargs) Module rhodecode.controllers.changeset:2 in before Module rhodecode.lib.auth:530 in __wrapper return func(*fargs, fkwargs) Module rhodecode.controllers.changeset:179 in before c.users_array = repo_model.get_users_js() Module rhodecode.model.repo:101 in get_users_js } for u in users] Module _sj:334 in dumps *kw).encode(obj) Module _sj.encoder:237 in encode chunks = self.iterencode(o, _one_shot=True) Module _sj.encoder:311 in iterencode return _iterencode(o, 0) UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 9: unexpected end of data

Removing the accent directly in the DB fixes the proble,

Comments (7)

  1. Ronald Kortekaas

    I have exactly the same problem (need to verify on Monday). And I have the idea that it's because the database is in latin1 and the unicode decode tries to decode it as utf8. As the character 0xe9 is a latin1 character and no utf8 (and there is no equal utf8 character for 0xe9).

    Marcin, when the database is created in MySQL, is the charset explicitly set as utf8? Or is it not specified. The default charset in MySQL is latin1 and can cause this kind of problems.

    I also happens on version 1.4.4

  2. Marcin Kuzminski repo owner

    By default sqlalchemy models have set explicitly mysql encoding as utf8, not sure how you got your db in latin1. I think such database should be converted to utf8, else i can see a lot of troubles :(

  3. Ronald Kortekaas

    I understand that it can create a problem. But currently it's the situation.

    I checked it and it definitely is the problem that my database is in latin1. I think it will be good to add a constraint that the database need to be in utf8.

    Before installation I already created the database with MySQL and gave the right permissions to the user under which Rhodecode accesses the database. Default this is in latin1 and so it stayed latin1. But if there is maybe the possibility to check the database charset and collation and maybe alter it when it's wrong?

  4. Marcin Kuzminski repo owner

    AFAIR sqlalchemy should force tables to be utf8 because in models i explicitly define that. But it's mysql you never know :) I think you can easily change charset to utf8 with few simple commands in existing database.

  5. Ronald Kortekaas

    So maybe it's a bug in SQLAlchemy. Because I checked also all the tables (you can define it for e.g. database, tables etc.) and they are all latin1. Hopefully I can try tonight to change the charset and collation. But I hope that it will not cause any problems.

  6. Log in to comment