mozilla-bmo1464766.patch
author Wolfgang Rosenauer <wr@rosenauer.org>
Sat, 23 Jun 2018 09:14:31 +0200
changeset 1060 5ce9d1f6be41
parent 1059 936bf8851c57
permissions -rw-r--r--
new beta
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1059
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     1
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     2
# HG changeset patch
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     3
# User Mike Hommey <mh+mozilla@glandium.org>
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     4
# Date 1527491713 -32400
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     5
# Node ID c28becad0c10b906454d7e424f9a9402799ea8dd
1060
5ce9d1f6be41 new beta
Wolfgang Rosenauer <wr@rosenauer.org>
parents: 1059
diff changeset
     6
# Parent  86eaa6799cf51660c0b598937121305b8f70c84d
1059
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     7
Bug 1464766 - Allow to relax the addon signature requirements. r?rhelmer
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     8
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     9
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    10
--- a/modules/libpref/init/all.js
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    11
+++ b/modules/libpref/init/all.js
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    12
@@ -1134,16 +1134,19 @@ pref("print.print_via_parent", true);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    13
 pref("print.print_via_parent", false);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    14
 #endif
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    15
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    16
 // Pref used by the spellchecker extension to control the
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    17
 // maximum number of misspelled words that will be underlined
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    18
 // in a document.
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    19
 pref("extensions.spellcheck.inline.max-misspellings", 500);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    20
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    21
+// Add-on manager scoped allowing unsigned addons. None by default.
1060
5ce9d1f6be41 new beta
Wolfgang Rosenauer <wr@rosenauer.org>
parents: 1059
diff changeset
    22
+pref("extensions.unsignedScopes", 12, locked);
1059
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    23
+
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    24
 // Prefs used by libeditor. Prefs specific to seamonkey composer
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    25
 // belong in comm-central/editor/ui/composer.js
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    26
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    27
 pref("editor.use_custom_colors", false);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    28
 pref("editor.singleLine.pasteNewlines",      2);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    29
 pref("editor.use_css",                       false);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    30
 pref("editor.css.default_length_unit",       "px");
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    31
 pref("editor.resizing.preserve_ratio",       true);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    32
diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    33
--- a/toolkit/mozapps/extensions/content/extensions.js
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    34
+++ b/toolkit/mozapps/extensions/content/extensions.js
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    35
@@ -42,16 +42,17 @@ XPCOMUtils.defineLazyPreferenceGetter(th
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    36
 const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    37
 const PREF_DISCOVER_ENABLED = "extensions.getAddons.showPane";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    38
 const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    39
 const PREF_GETADDONS_CACHE_ID_ENABLED = "extensions.%ID%.getAddons.cache.enabled";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    40
 const PREF_UI_TYPE_HIDDEN = "extensions.ui.%TYPE%.hidden";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    41
 const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    42
 const PREF_LEGACY_EXCEPTIONS = "extensions.legacy.exceptions";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    43
 const PREF_LEGACY_ENABLED = "extensions.legacy.enabled";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    44
+const PREF_UNSIGNED_SCOPES = "extensions.unsignedScopes";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    45
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    46
 const LOADING_MSG_DELAY = 100;
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    47
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    48
 const UPDATES_RECENT_TIMESPAN = 2 * 24 * 3600000; // 2 days (in milliseconds)
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    49
 const UPDATES_RELEASENOTES_TRANSFORMFILE = "chrome://mozapps/content/extensions/updateinfo.xsl";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    50
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    51
 const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/parsererror.xml";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    52
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    53
@@ -223,19 +224,21 @@ function loadView(aViewId) {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    54
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    55
 function isCorrectlySigned(aAddon) {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    56
   // Add-ons without an "isCorrectlySigned" property are correctly signed as
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    57
   // they aren't the correct type for signing.
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    58
   return aAddon.isCorrectlySigned !== false;
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    59
 }
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    60
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    61
 function isDisabledUnsigned(addon) {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    62
-  let signingRequired = (addon.type == "locale") ?
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    63
-                        AddonSettings.LANGPACKS_REQUIRE_SIGNING :
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    64
-                        AddonSettings.REQUIRE_SIGNING;
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    65
+  let unsignedScopes = Services.prefs.getIntPref(PREF_UNSIGNED_SCOPES, 0);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    66
+  let signingRequired = !(addon.scope & unsignedScopes) &&
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    67
+                        ((addon.type == "locale") ?
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    68
+                         AddonSettings.LANGPACKS_REQUIRE_SIGNING :
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    69
+                         AddonSettings.REQUIRE_SIGNING);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    70
   return signingRequired && !isCorrectlySigned(addon);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    71
 }
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    72
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    73
 function isLegacyExtension(addon) {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    74
   let legacy = false;
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    75
   if (addon.type == "extension" && !addon.isWebExtension) {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    76
     legacy = true;
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    77
   }
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    78
diff --git a/toolkit/mozapps/extensions/internal/XPIDatabase.jsm b/toolkit/mozapps/extensions/internal/XPIDatabase.jsm
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    79
--- a/toolkit/mozapps/extensions/internal/XPIDatabase.jsm
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    80
+++ b/toolkit/mozapps/extensions/internal/XPIDatabase.jsm
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    81
@@ -78,16 +78,17 @@ const KEY_PROFILEDIR                  = 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    82
 const FILE_JSON_DB                    = "extensions.json";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    83
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    84
 // The last version of DB_SCHEMA implemented in SQLITE
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    85
 const LAST_SQLITE_DB_SCHEMA           = 14;
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    86
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    87
 const PREF_BLOCKLIST_ITEM_URL         = "extensions.blocklist.itemURL";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    88
 const PREF_DB_SCHEMA                  = "extensions.databaseSchema";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    89
 const PREF_EM_AUTO_DISABLED_SCOPES    = "extensions.autoDisableScopes";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    90
+const PREF_EM_UNSIGNED_SCOPES         = "extensions.unsignedScopes";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    91
 const PREF_EM_EXTENSION_FORMAT        = "extensions.";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    92
 const PREF_PENDING_OPERATIONS         = "extensions.pendingOperations";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    93
 const PREF_XPI_SIGNATURES_DEV_ROOT    = "xpinstall.signatures.dev-root";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    94
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    95
 const TOOLKIT_ID                      = "toolkit@mozilla.org";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    96
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    97
 const KEY_APP_SYSTEM_ADDONS           = "app-system-addons";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    98
 const KEY_APP_SYSTEM_DEFAULTS         = "app-system-defaults";
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    99
@@ -1959,17 +1960,19 @@ this.XPIDatabase = {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   100
    * Calculates whether an add-on should be appDisabled or not.
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   101
    *
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   102
    * @param {AddonInternal} aAddon
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   103
    *        The add-on to check
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   104
    * @returns {boolean}
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   105
    *        True if the add-on should not be appDisabled
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   106
    */
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   107
   isUsableAddon(aAddon) {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   108
-    if (this.mustSign(aAddon.type) && !aAddon.isCorrectlySigned) {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   109
+    let unsignedScopes = Services.prefs.getIntPref(PREF_EM_UNSIGNED_SCOPES, 0);
1060
5ce9d1f6be41 new beta
Wolfgang Rosenauer <wr@rosenauer.org>
parents: 1059
diff changeset
   110
+    if (!(aAddon._installLocation.scope & unsignedScopes) &&
1059
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   111
+        this.mustSign(aAddon.type) && !aAddon.isCorrectlySigned) {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   112
       logger.warn(`Add-on ${aAddon.id} is not correctly signed.`);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   113
       if (Services.prefs.getBoolPref(PREF_XPI_SIGNATURES_DEV_ROOT, false)) {
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   114
         logger.warn(`Preference ${PREF_XPI_SIGNATURES_DEV_ROOT} is set.`);
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   115
       }
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   116
       return false;
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   117
     }
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   118
 
936bf8851c57 try to make langpacks work again
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   119
     if (aAddon.blocklistState == nsIBlocklistService.STATE_BLOCKED) {