Bug 19278 - User alias with UTF-8 character are not working
Summary: User alias with UTF-8 character are not working
Status: RESOLVED FIXED
Alias: None
Product: Telepathy
Classification: Unclassified
Component: butterfly (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium minor
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-24 06:28 UTC by Aurélien Bauchet
Modified: 2008-12-28 06:51 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Utf-8 mishandling workaround patch (703 bytes, patch)
2008-12-24 06:55 UTC, Aurélien Bauchet
Details | Splinter Review
tp-butterfly utf-8 mishandling user aliases patch (705 bytes, patch)
2008-12-26 06:59 UTC, Aurélien Bauchet
Details | Splinter Review

Description Aurélien Bauchet 2008-12-24 06:28:01 UTC
Bug found in the latest release of pymsn : 0.3.3
Telepathy-butterfly version : 0.3.2

Trying to set an user alias containing special UTF-8 character such as "é" in french, does not work. Nothing happens on Empathy side.

On the telepathy-butterfly side, when setting the alias using D-Feet via the SetAliases method of the connector, the following error is returned from Pymsn:

org.freedesktop.DBus.Python.KeyError: Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/dbus/service.py", line 702, in _message_cb
    retval = candidate_method(self, *args, **keywords)
  File "/usr/lib/python2.5/site-packages/butterfly/aliasing.py", line 80, in SetAliases
    self.msn_client.profile.display_name = alias
  File "/usr/lib/python2.5/site-packages/pymsn/profile.py", line 395, in fset
    self._ns_client.set_display_name(display_name)
  File "/usr/lib/python2.5/site-packages/pymsn/util/decorator.py", line 111, in new_function
    func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/pymsn/msnp/notification.py", line 147, in set_display_name
    ('MFN', urllib.quote(display_name)))
  File "/usr/lib/python2.5/urllib.py", line 1205, in quote
    res = map(safe_map.__getitem__, s)
KeyError: u'\xe9'

This seems to correspond to a mishandling of some utf-8 characters.

When setting a user alias without any accent, for instance, it works flawlessly and it's propagated to the contacts.
Comment 1 Aurélien Bauchet 2008-12-24 06:55:35 UTC
Created attachment 21469 [details] [review]
Utf-8 mishandling workaround patch

The bug can be reproduced directly in a python shell:

>>> import urllib
>>> urllib.quote(u'Aurélien')
/usr/lib/python2.5/urllib.py:1205: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  res = map(safe_map.__getitem__, s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/urllib.py", line 1205, in quote
    res = map(safe_map.__getitem__, s)
KeyError: u'\xe9'

It seems to be a known problem:
http://coding.derkeiler.com/Archive/Python/comp.lang.python/2008-10/msg00432.html

Using the hint provided before, I create a patch that corrects this error. It mainly encode the utf-8 string before the quote.
Comment 2 Ali Sabil 2008-12-24 07:29:08 UTC
pymsn expects all user strings to be utf-8 encoded string instances (not unicode instance). To me it seems that the program you are using is not using pymsn correctly.
Comment 3 Aurélien Bauchet 2008-12-26 02:39:43 UTC
Well, the application using it is the telepathy-butterly connector, the main and only application (to my knowlegde) using the pymsn library.

Then, should this bug be assigned to the telepathy-butterfly team then, if you consider it's not a pymsn bug?
Comment 4 Ali Sabil 2008-12-26 05:20:24 UTC
yes, please do as I am no longer the maintainer of telepathy-butterfly.
Comment 5 Aurélien Bauchet 2008-12-26 06:59:38 UTC
Created attachment 21494 [details] [review]
tp-butterfly utf-8 mishandling user aliases patch

Correct the mentionned bug but in the telepathy-butterfly source code. It's seems that indeed the encode method was missing as it was applied to alias for classic contact aliases.

Works on 0.3.2 release of telepathy-butterfly
Comment 6 Aurélien Bauchet 2008-12-26 07:00:33 UTC
Reassigning it to the telepathy-butterfly team.
Comment 7 Jonny Lamb 2008-12-28 06:51:32 UTC
commit 43a961b920edf21f83e6478385d172fd9eb660aa
Author: Jonny Lamb <jonny.lamb@collabora.co.uk>
Date:   Sun Dec 28 14:48:32 2008 +0000

    Encode the user alias as UTF-8 when setting a new display name.

    "It seems that indeed the encode method was missing as it was applied to
    alias for classic contact aliases."

    Thanks to Aurélien Bauchet <baucheta@gmail.com> for the patch.

    Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.