Skip to content

Commit bbf5dc5

Browse files
mkaplypchevrel@mozilla.com
authored andcommitted
Bug 2047962 - Unwrap legacy data:text/plain, pref values in autoconfig. ,Gijs a=pascalc
Original Revision: https://phabricator.services.mozilla.com/D309831 Differential Revision: https://phabricator.services.mozilla.com/D310632
1 parent 19bd4ee commit bbf5dc5

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎extensions/pref/autoconfig/src/prefcalls.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ function defaultPref(prefName, value) {
3737
try {
3838
var prefBranch = Services.prefs.getDefaultBranch(null);
3939
if (typeof value == "string") {
40+
// Unwrap the legacy homepage form that the localizable-pref reader used
41+
// to handle (bug 1490339). Match it exactly so we don't touch deliberate
42+
// data: URLs.
43+
var legacyPrefix = "data:text/plain,browser.startup.homepage=";
44+
if (
45+
prefName == "browser.startup.homepage" &&
46+
value.startsWith(legacyPrefix)
47+
) {
48+
value = value.substring(legacyPrefix.length);
49+
}
4050
if (gIsUTF8) {
4151
prefBranch.setStringPref(prefName, value);
4252
return;

‎extensions/pref/autoconfig/test/unit/autoconfig-all.cfg‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ pref("_autoconfig_.test.userpref", "userpref");
66
// Verify this one has a default pref
77
defaultPref("_autoconfig_.test.defaultpref", "defaultpref");
88

9+
// Verify the legacy homepage data:text/plain, wrapper is unwrapped
10+
defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=http://www.example.com/");
11+
12+
// Verify the same wrapper on any other pref is left untouched
13+
defaultPref("_autoconfig_.test.datapref", "data:text/plain,_autoconfig_.test.datapref=datapref");
14+
915
// Verify this one is locked
1016
lockPref("_autoconfig_.test.lockpref", "lockpref");
1117

‎extensions/pref/autoconfig/test/unit/test_autoconfig.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ function run_test() {
4242
);
4343
equal("defaultpref", prefs.getStringPref("_autoconfig_.test.defaultpref"));
4444

45+
equal(
46+
"http://www.example.com/",
47+
prefs.getStringPref("browser.startup.homepage")
48+
);
49+
50+
equal(
51+
"data:text/plain,_autoconfig_.test.datapref=datapref",
52+
prefs.getStringPref("_autoconfig_.test.datapref")
53+
);
54+
4555
ok(prefs.prefIsLocked("_autoconfig_.test.lockpref"));
4656
equal("lockpref", prefs.getStringPref("_autoconfig_.test.lockpref"));
4757

0 commit comments

Comments
 (0)