Bug 783858 - Unicode in script names breaks scratchpad's recent files; r=rcampbell

This commit is contained in:
Anton Kovalyov 2012-10-23 11:28:37 -07:00
Родитель 51c2f371a3
Коммит 56f8757dee
2 изменённых файлов: 30 добавлений и 13 удалений

Просмотреть файл

@ -729,13 +729,16 @@ var Scratchpad = {
*/
getRecentFiles: function SP_getRecentFiles()
{
let maxRecent = Services.prefs.getIntPref(PREF_RECENT_FILES_MAX);
let branch = Services.prefs.
getBranch("devtools.scratchpad.");
let branch = Services.prefs.getBranch("devtools.scratchpad.");
let filePaths = [];
// WARNING: Do not use getCharPref here, it doesn't play nicely with
// Unicode strings.
if (branch.prefHasUserValue("recentFilePaths")) {
filePaths = JSON.parse(branch.getCharPref("recentFilePaths"));
let data = branch.getComplexValue("recentFilePaths",
Ci.nsISupportsString).data;
filePaths = JSON.parse(data);
}
return filePaths;
@ -781,10 +784,16 @@ var Scratchpad = {
filePaths.push(aFile.path);
let branch = Services.prefs.
getBranch("devtools.scratchpad.");
branch.setCharPref("recentFilePaths", JSON.stringify(filePaths));
return;
// WARNING: Do not use setCharPref here, it doesn't play nicely with
// Unicode strings.
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = JSON.stringify(filePaths);
let branch = Services.prefs.getBranch("devtools.scratchpad.");
branch.setComplexValue("recentFilePaths",
Ci.nsISupportsString, str);
},
/**
@ -868,11 +877,19 @@ var Scratchpad = {
let filePaths = this.getRecentFiles();
if (maxRecent < filePaths.length) {
let branch = Services.prefs.
getBranch("devtools.scratchpad.");
let diff = filePaths.length - maxRecent;
filePaths.splice(0, diff);
branch.setCharPref("recentFilePaths", JSON.stringify(filePaths));
// WARNING: Do not use setCharPref here, it doesn't play nicely with
// Unicode strings.
let str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = JSON.stringify(filePaths);
let branch = Services.prefs.getBranch("devtools.scratchpad.");
branch.setComplexValue("recentFilePaths",
Ci.nsISupportsString, str);
}
}
},

Просмотреть файл

@ -27,7 +27,7 @@ var lists = {
// Temporary file names.
let gFileName01 = "file01_ForBug651942.tmp"
let gFileName02 = "file02_ForBug651942.tmp"
let gFileName02 = "☕" // See bug 783858 for more information
let gFileName03 = "file03_ForBug651942.tmp"
let gFileName04 = "file04_ForBug651942.tmp"