Bug 1065208 - Decode and quote ssid when it is in utf-8 format. r=vchang
authorKai-Zhen Li <kli@mozilla.com>
Thu, 23 Oct 2014 17:19:24 +0800
changeset 212451 db4b9d9913b9f6db3d4cfcd5a8639c3a23fd190f
parent 212398 cf1a9a16429bd6bea71a0aa3550a1fbf76a0d65a
child 212452 404b90b5b086180d7ce84c1b85d6c4ca42699f70
push id27713
push userkwierso@gmail.com
push dateMon, 27 Oct 2014 21:49:10 +0000
treeherdermozilla-central@d0cd2665184a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvchang
bugs1065208
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1065208 - Decode and quote ssid when it is in utf-8 format. r=vchang
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -1210,16 +1210,22 @@ var WifiManager = (function() {
     var done = 0;
     for (var n = 0; n < networkConfigurationFields.length; ++n) {
       let fieldName = networkConfigurationFields[n].name;
       let fieldType = networkConfigurationFields[n].type;
       wifiCommand.getNetworkVariable(netId, fieldName, function(value) {
         if (value !== null) {
           if (fieldType === "integer") {
             config[fieldName] = parseInt(value, 10);
+          } else if ( fieldName == "ssid" && value[0] != '"' ) {
+            // SET_NETWORK will set a quoted ssid to wpa_supplicant.
+            // But if ssid contains non-ascii char, it will be converted into utf-8.
+            // For example: "Test的wifi" --> 54657374e79a8477696669
+            // When GET_NETWORK receive a un-quoted utf-8 ssid, it must be decoded and quoted.
+            config[fieldName] = quote(decodeURIComponent(value.replace(/[0-9a-f]{2}/g, '%$&')));
           } else {
             // value is string type by default.
             config[fieldName] = value;
           }
         }
         if (++done == networkConfigurationFields.length)
           callback(config);
       });