mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-23 16:55:46 +01:00
Forbid plugins access to commands.add.
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
// given in the LICENSE.txt file included with this file.
|
// given in the LICENSE.txt file included with this file.
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
function isDactyl(frame) /^resource:\/\/dactyl\S+( -> resource:\/\/dactyl(?!-content\/eval.js)\S+)?$/.test(frame.filename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
Components.utils.import("resource://dactyl/bootstrap.jsm");
|
||||||
@@ -440,7 +442,8 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
|
|||||||
repeat: null,
|
repeat: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new command.
|
* Adds a new command to the builtin hive. Accessible only to core
|
||||||
|
* dactyl code. Plugins should use group.commands.add instead.
|
||||||
*
|
*
|
||||||
* @param {string[]} names The names by which this command can be
|
* @param {string[]} names The names by which this command can be
|
||||||
* invoked. The first name specified is the command's canonical
|
* invoked. The first name specified is the command's canonical
|
||||||
@@ -686,7 +689,11 @@ var Commands = Module("commands", {
|
|||||||
/** @property {string} The last executed Ex command line. */
|
/** @property {string} The last executed Ex command line. */
|
||||||
repeat: null,
|
repeat: null,
|
||||||
|
|
||||||
add: function add() this.builtin._add.apply(this.builtin, arguments),
|
add: function add() {
|
||||||
|
util.assert(isDactyl(Components.stack.caller),
|
||||||
|
"User scripts may not add builtin commands. Please use group.commands.add instead.");
|
||||||
|
return this.builtin._add.apply(this.builtin, arguments);
|
||||||
|
},
|
||||||
addUserCommand: deprecated("group.commands.add", { get: function addUserCommand() this.user.closure._add }),
|
addUserCommand: deprecated("group.commands.add", { get: function addUserCommand() this.user.closure._add }),
|
||||||
getUserCommands: deprecated("iter(group.commands)", function getUserCommands() iter(this.user).toArray()),
|
getUserCommands: deprecated("iter(group.commands)", function getUserCommands() iter(this.user).toArray()),
|
||||||
removeUserCommand: deprecated("group.commands.remove", { get: function removeUserCommand() this.user.closure.remove }),
|
removeUserCommand: deprecated("group.commands.remove", { get: function removeUserCommand() this.user.closure.remove }),
|
||||||
|
|||||||
Reference in New Issue
Block a user