Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorSascha Silbe <silbe@activitycentral.com>2012-04-02 12:18:41 (GMT)
committer Sascha Silbe <silbe@activitycentral.com>2012-04-10 18:23:04 (GMT)
commit7f8ba95a66780828531eba0494e004757bf45c71 (patch)
tree555170aeb61c920aadd6f2996140902298b02d27 /extensions
parentb0cd1c99318f5fd95d254b263cd53b3f852c527a (diff)
Don't treat SSID as UTF-8 character sequence (fixes SL#2023)
IEEE 802.11 [2] defines the SSID as a sequence of octets (i.e. bytes), but Sugar treated it as UTF-8 character data. While in most cases the SSID is actually some human-readable string, there's neither a guarantee for that nor does any (de-facto or de-jure) standard specify the encoding to use. As a result, we'll encounter SSIDs in a large variety of encodings and will also need to cope with arbitrary byte strings. Any assumption of a single (or in fact any) character encoding is incorrect. The D-Bus API of NetworkManager 0.9 [3] passes SSIDs as uninterpreted byte strings (D-Bus signature "ay"). Before SSIDs can be displayed on screen, some kind of interpretation must happen. NetworkManager has a rather elaborate heuristic that takes the user locale into account. In the future (i.e. when the NetworkManager client code in Sugar has been ported to gobject-introspection) we may use nm_utils_ssid_to_utf8() [4], but for now we're doing the following to allow the user to use non-UTF-8 APs at all: 1. If the SSID is a valid character string consisting only of printable characters in one of the following encodings (tried in the given order), decode it accordingly: UTF-8, ISO-8859-1, Windows-1251. 2. Return a hex dump of the SSID. The first rule should cover the majority of current Sugar users and hopefully all AP vendors will switch to UTF-8 eventually. In the meantime, the second rule allows users to distinguish between several APs with SSIDs in unknown encodings (or even using arbitrary byte sequences that don't _have_ a character representation). Tested: - filtering on ASCII and non-ASCII parts of the name of and connecting to: - an unsecured AP with a UTF-8 SSID ("äöü߀sugartest", HostAP) - an unsecured AP with an ISO-8859-1 SSID ("äöüßsugartest", HostAP) - an unsecured AP with a non-character SSID (0d:06:f0:0d, HostAP) - a WEP-secured AP with a UTF-8 name ("äöü߀sugartest2", HostAP) - a WEP-secured AP with an ISO-8859-1 name ("äöüßsugartest2", HostAP) - a WEP-secured AP with a non-character SSID (0d:06:f0:0d, HostAP) - a WPA-secured AP with an ASCII name (COTS AP) In each case the name was displayed correctly in a) the palette of the AP icon in the Neighbourhood, b) the palette of the wireless network Frame device and c) the title of the WLAN credentials (WEP/WPA passphrase) dialog (for the WEP/WPA cases). [1] https://bugs.sugarlabs.org/ticket/2023 [2] http://standards.ieee.org/getieee802/download/802.11-2007.pdf [3] http://projects.gnome.org/NetworkManager/developers/api/09/spec.html [4] http://projects.gnome.org/NetworkManager/developers/libnm-util/09/libnm-util-nm-utils.html#nm-utils-ssid-to-utf8 Signed-off-by: Sascha Silbe <silbe@activitycentral.com> Reviewed-by: Daniel Drake <dsd@laptop.org>
Diffstat (limited to 'extensions')
-rw-r--r--extensions/deviceicon/network.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index 1beeb88..09a3abb 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -374,7 +374,8 @@ class WirelessDeviceView(ToolButton):
self._device = device
self._device_props = None
self._flags = 0
- self._name = ''
+ self._ssid = ''
+ self._display_name = ''
self._mode = network.NM_802_11_MODE_UNKNOWN
self._strength = 0
self._frequency = 0
@@ -394,7 +395,7 @@ class WirelessDeviceView(ToolButton):
self._icon.show()
self.set_palette_invoker(FrameWidgetInvoker(self))
- self._palette = WirelessPalette(self._name)
+ self._palette = WirelessPalette(self._display_name)
self._palette.connect('deactivate-connection',
self.__deactivate_connection_cb)
self.set_palette(self._palette)
@@ -471,7 +472,8 @@ class WirelessDeviceView(ToolButton):
self._mode = properties['Mode']
self._color = None
if 'Ssid' in properties:
- self._name = properties['Ssid']
+ self._ssid = properties['Ssid']
+ self._display_name = network.ssid_to_display_name(self._ssid)
self._color = None
if 'Strength' in properties:
self._strength = properties['Strength']
@@ -482,11 +484,11 @@ class WirelessDeviceView(ToolButton):
if self._color == None:
if self._mode == network.NM_802_11_MODE_ADHOC and \
- network.is_sugar_adhoc_network(self._name):
+ network.is_sugar_adhoc_network(self._ssid):
self._color = profile.get_color()
else:
sha_hash = hashlib.sha1()
- data = self._name + hex(self._flags)
+ data = self._ssid + hex(self._flags)
sha_hash.update(data)
digest = hash(sha_hash.digest())
index = digest % len(xocolor.colors)
@@ -508,7 +510,8 @@ class WirelessDeviceView(ToolButton):
else:
self._icon.props.badge_name = None
- self._palette.props.primary_text = glib.markup_escape_text(self._name)
+ label = glib.markup_escape_text(self._display_name)
+ self._palette.props.primary_text = label
self._update_state()
self._update_color()
@@ -520,7 +523,7 @@ class WirelessDeviceView(ToolButton):
state = network.NM_DEVICE_STATE_UNKNOWN
if self._mode != network.NM_802_11_MODE_ADHOC and \
- network.is_sugar_adhoc_network(self._name) == False:
+ network.is_sugar_adhoc_network(self._ssid) == False:
if state == network.NM_DEVICE_STATE_ACTIVATED:
icon_name = '%s-connected' % 'network-wireless'
else: