[Sugar-devel] [PATCH sugar] Do not display APs that announce the ssid in invalid utf-8 data, OLPC #11698

Simon Schampijer simon at schampijer.de
Tue Mar 27 04:19:30 EDT 2012


Sugar is not doing well in dealing with non-utf8 data. If an AP
does not announce the ssid in valid utf-8 data Sugar will fail in
certain ways. For example, currently if an AP does not announce
the ssid in correct utf-8 data Sugar does display an AP but it has
no name in the Palette. If you try to connect to that AP Sugar does
silently fail because it is trying to sent this string over D-Bus
and that chokes on not being valid utf-8 data. The same AP might be
displayed correctly under GNOME, since NM-applet is doing
guessing for the right ssid [1].

In some cases Sugar will crash when feeded non utf-8 compliant data,
as ssid which segfaults glib.markup_escape_text when trying to display
the ssid: glib.markup_escape_text does assume correct utf8 data to be
passed [3].

The patch does check early when the AP is announced by NM and verify
that we do have a ssid with valid utf-8 data. If not, we don't display
the AP and log a debug message.

In the future we can use GLib.utf8_validate [5] to verify a string
before passing to Glib.markup_escape_text and doing more advanced
guessing like done in nm-utils-ssid-to-utf8 [1] but the patch is
enough for now and has seen testing in the field already.

Signed-off-by: Simon Schampijer <simon at laptop.org>

[1] http://developer.gnome.org/libnm-util/unstable/libnm-util-nm-utils.html#nm-utils-ssid-to-utf8
[2] http://dev.laptop.org/ticket/11698
[3] http://developer.gnome.org/pygobject/stable/glib-functions.html#function-glib--markup-escape-text
[4] https://bugzilla.gnome.org/show_bug.cgi?id=672546
[5] http://developer.gnome.org/glib/2.30/glib-Unicode-Manipulation.html#g-utf8-validate
---
 src/jarabe/desktop/meshbox.py |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index 2ce6163..0f97ab7 100644
--- a/src/jarabe/desktop/meshbox.py
+++ b/src/jarabe/desktop/meshbox.py
@@ -548,6 +548,13 @@ class MeshBox(gtk.VBox):
             ap.disconnect()
             return
 
+        try:
+            unicode(ap.name, 'utf-8')
+        except UnicodeDecodeError:
+            logging.debug('ignoring an AP essid that is not utf-8 compliant')
+            ap.disconnect()
+            return
+
         if self._adhoc_manager is not None and \
                 network.is_sugar_adhoc_network(ap.name) and \
                 ap.mode == network.NM_802_11_MODE_ADHOC:
-- 
1.7.7.6



More information about the Sugar-devel mailing list