[Pkg-mozext-commits] [wot] 119/226: Fixed #52 Cyrillic in categories doesn't work
David Prévot
taffit at moszumanska.debian.org
Fri May 1 00:35:42 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository wot.
commit 9a13183000c5c97b100e82051aaa5f426209c233
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date: Fri Aug 23 14:43:34 2013 +0300
Fixed #52 Cyrillic in categories doesn't work
---
content/categories.js | 8 ++++----
content/prefs.js | 12 +++++++-----
content/util.js | 8 ++++++++
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/content/categories.js b/content/categories.js
index edc9344..de8c1be 100644
--- a/content/categories.js
+++ b/content/categories.js
@@ -90,7 +90,7 @@ var wot_categories = {
res_grouping.push(gs_obj);
}
- wot_prefs.setChar(this.PREF_GROUPINGS + ".all", JSON.stringify(res_grouping));
+ wot_prefs.setChar(this.PREF_GROUPINGS + ".all", JSON.stringify(res_grouping), true);
}
// remove all categories from prefs
@@ -111,7 +111,7 @@ var wot_categories = {
// this.categories[cat_obj.id] = cat_obj;
- wot_prefs.setChar(this.PREF_CATEGORY + "." + cat_obj.name, JSON.stringify(cat_obj));
+ wot_prefs.setChar(this.PREF_CATEGORY + "." + cat_obj.name, JSON.stringify(cat_obj), true); // using utf8
}
this.init_categories();
@@ -132,7 +132,7 @@ var wot_categories = {
for (var i = 0; i < children.length; i++) {
try {
var cat_id = children[i];
- var cat_json = wot_prefs.getChar(this.PREF_CATEGORY + "." + cat_id, "{}");
+ var cat_json = wot_prefs.getChar(this.PREF_CATEGORY + "." + cat_id, "{}", true); // using utf8
var cat = JSON.parse(cat_json);
if (!wot_util.isEmpty(cat)) this.categories[cat_id] = cat;
} catch (e) {
@@ -143,7 +143,7 @@ var wot_categories = {
}
}
- var groupings_json = wot_prefs.getChar(this.PREF_GROUPINGS + ".all", "{}");
+ var groupings_json = wot_prefs.getChar(this.PREF_GROUPINGS + ".all", "{}", true); //using utf8
this.grouping = JSON.parse(groupings_json);
this.inited = true;
diff --git a/content/prefs.js b/content/prefs.js
index d6322ec..26e5a4a 100644
--- a/content/prefs.js
+++ b/content/prefs.js
@@ -170,12 +170,13 @@ var wot_prefs =
return false;
},
- getChar: function(name, default_value)
+ getChar: function(name, default_value, safe_utf8)
{
try {
- if (this.pref.getPrefType(WOT_PREF +
- name) == this.pref.PREF_STRING) {
- return this.pref.getCharPref(WOT_PREF + name);
+ if (this.pref.getPrefType(WOT_PREF + name) == this.pref.PREF_STRING) {
+ var res = this.pref.getCharPref(WOT_PREF + name);
+
+ return safe_utf8 ? wot_util.decode_utf8(res) : res; // decode from utf8
}
} catch (e) {
dump("wot_prefs.getChar(" + name + "): failed with " + e + "\n");
@@ -183,9 +184,10 @@ var wot_prefs =
return default_value;
},
- setChar: function(name, value)
+ setChar: function(name, value, safe_utf8)
{
try {
+ value = safe_utf8 ? wot_util.encode_utf8(value) : value; // endode to utf8 if needed
this.pref.setCharPref(WOT_PREF + name, value);
return true;
} catch (e) {
diff --git a/content/util.js b/content/util.js
index d087900..d57b475 100644
--- a/content/util.js
+++ b/content/util.js
@@ -114,6 +114,14 @@ var wot_util =
return obj;
},
+ encode_utf8: function (s) {
+ return unescape(encodeURIComponent(s));
+ },
+
+ decode_utf8: function (s) {
+ return decodeURIComponent(escape(s));
+ },
+
time_sincefirstrun: function()
{
try {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/wot.git
More information about the Pkg-mozext-commits
mailing list