aboutsummaryrefslogtreecommitdiffstats
path: root/platform
diff options
context:
space:
mode:
authorgorhill <rhill@raymondhill.net>2015-08-18 08:58:06 -0400
committergorhill <rhill@raymondhill.net>2015-08-18 08:58:06 -0400
commit5366697a0c4a10df5a19b76989f2c95e7bbefc6d (patch)
tree56db6d23e2dd195e0e3825b6e6558aa4b7c0e09b /platform
parentf29628ee019031bf6e0f195cb4d0f6544664f3a4 (diff)
downloaduBlock-5366697a0c4a10df5a19b76989f2c95e7bbefc6d.zip
uBlock-5366697a0c4a10df5a19b76989f2c95e7bbefc6d.tar.gz
uBlock-5366697a0c4a10df5a19b76989f2c95e7bbefc6d.tar.bz2
this fixes https://github.com/gorhill/uBlock/issues/80#issuecomment-132081658
get/setComplexValue must be used to ensure proper handling of Unicode string in `about:config`.
Diffstat (limited to 'platform')
-rw-r--r--platform/firefox/vapi-background.js26
1 files changed, 19 insertions, 7 deletions
diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js
index f78f693..aece135 100644
--- a/platform/firefox/vapi-background.js
+++ b/platform/firefox/vapi-background.js
@@ -351,7 +351,7 @@ vAPI.storage = (function() {
var row;
- while ( row = rows.getNextRow() ) {
+ while ( (row = rows.getNextRow()) ) {
// we assume that there will be two columns, since we're
// using it only for preferences
result[row.getResultByIndex(0)] = row.getResultByIndex(1);
@@ -2936,6 +2936,13 @@ vAPI.cloud = (function() {
var extensionBranchPath = 'extensions.' + location.host;
var cloudBranchPath = extensionBranchPath + '.cloudStorage';
+ // https://github.com/gorhill/uBlock/issues/80#issuecomment-132081658
+ // We must use get/setComplexValue in order to properly handle strings
+ // with unicode characters.
+ var iss = Ci.nsISupportsString;
+ var argstr = Components.classes['@mozilla.org/supports-string;1']
+ .createInstance(iss);
+
var options = {
defaultDeviceName: '',
deviceName: ''
@@ -2945,7 +2952,8 @@ vAPI.cloud = (function() {
try {
options.deviceName = Services.prefs
.getBranch(extensionBranchPath + '.')
- .getCharPref('deviceName');
+ .getComplexValue('deviceName', iss)
+ .data;
} catch(ex) {
}
@@ -2954,7 +2962,8 @@ vAPI.cloud = (function() {
try {
name = Services.prefs
.getBranch('services.sync.client.')
- .getCharPref('name');
+ .getComplexValue('name', iss)
+ .data;
} catch(ex) {
}
@@ -2966,11 +2975,12 @@ vAPI.cloud = (function() {
var syncBranch = Services.prefs.getBranch('services.sync.prefs.sync.');
// Mark config entries as syncable
+ argstr.data = '';
var dataKey;
for ( var i = 0; i < dataKeys.length; i++ ) {
dataKey = dataKeys[i];
if ( extensionBranch.prefHasUserValue('cloudStorage.' + dataKey) === false ) {
- extensionBranch.setCharPref('cloudStorage.' + dataKey, '');
+ extensionBranch.setComplexValue('cloudStorage.' + dataKey, iss, argstr);
}
syncBranch.setBoolPref(cloudBranchPath + '.' + dataKey, true);
}
@@ -2985,7 +2995,8 @@ vAPI.cloud = (function() {
'size': 0
};
bin.size = JSON.stringify(bin).length;
- branch.setCharPref(datakey, JSON.stringify(bin));
+ argstr.data = JSON.stringify(bin);
+ branch.setComplexValue(datakey, iss, argstr);
if ( typeof callback === 'function' ) {
callback();
}
@@ -2995,7 +3006,7 @@ vAPI.cloud = (function() {
var result = null;
var branch = Services.prefs.getBranch(cloudBranchPath + '.');
try {
- var json = branch.getCharPref(datakey);
+ var json = branch.getComplexValue(datakey, iss).data;
if ( typeof json === 'string' ) {
result = JSON.parse(json);
}
@@ -3020,7 +3031,8 @@ vAPI.cloud = (function() {
var branch = Services.prefs.getBranch(extensionBranchPath + '.');
if ( typeof details.deviceName === 'string' ) {
- branch.setCharPref('deviceName', details.deviceName);
+ argstr.data = details.deviceName;
+ branch.setComplexValue('deviceName', iss, argstr);
options.deviceName = details.deviceName;
}