Bug 269739 - Limit command recursion to 10 levels.

ChatZilla only.
r=samuel
This commit is contained in:
silver%warwickcompsoc.co.uk 2006-07-18 17:01:10 +00:00
Родитель 2d2ebdd1b1
Коммит a0a02fe0e0
4 изменённых файлов: 34 добавлений и 2 удалений

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

@ -172,6 +172,9 @@ function CommandManager (defaultBundle)
{
this.commands = new Object();
this.defaultBundle = defaultBundle;
this.currentDispatchDepth = 0;
this.maxDispatchDepth = 10;
this.dispatchUnwinding = false;
}
CommandManager.prototype.defaultFlags = 0;

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

@ -381,6 +381,21 @@ function dispatch(text, e, isInteractive, flags)
case 1:
/* one match, good for you */
var cm = client.commandManager;
if (cm.currentDispatchDepth >= cm.maxDispatchDepth)
{
/* We've reatched the max dispatch depth, so we need to unwind
* the entire stack of commands.
*/
cm.dispatchUnwinding = true;
}
// Don't start any new commands while unwinding.
if (cm.dispatchUnwinding)
break;
cm.currentDispatchDepth++;
var ex;
try
{
@ -396,6 +411,19 @@ function dispatch(text, e, isInteractive, flags)
else
dd(formatException(ex), MT_ERROR);
}
cm.currentDispatchDepth--;
if (cm.dispatchUnwinding && (cm.currentDispatchDepth == 0))
{
/* Last level to unwind, and this is where we display the
* message. We need to leave it until here because displaying
* a message invokes a couple of commands itself, and we need
* to not be right on the dispatch limit for that.
*/
cm.dispatchUnwinding = false;
display(getMsg(MSG_ERR_MAX_DISPATCH_DEPTH, ary[0].name),
MT_ERROR);
}
break;
default:

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

@ -43,7 +43,7 @@ const __cz_version = "0.9.74";
const __cz_condition = "green";
const __cz_suffix = "";
const __cz_guid = "59c81df5-4b7a-477b-912d-4e0fdf64e5f2";
const __cz_locale = "0.9.74";
const __cz_locale = "0.9.74.1";
var warn;
var ASSERT;

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

@ -69,7 +69,7 @@
#
### End of notes ###
locale.version = 0.9.74
locale.version = 0.9.74.1
locale.error = You are using ChatZilla %1$S, which requires the locale version %2$S. The currently selected locale, %3$S, is version %4$S, and therefore there may be problems running ChatZilla.\n\nIt is strongly advised that you update or remove the ChatZilla locale in question.
# Misc
@ -709,6 +709,7 @@ msg.err.notimplemented = Sorry, ``%1$S'' has not been implemented.
msg.err.required.param = Missing required parameter %1$S.
msg.err.ambigcommand = Ambiguous command, ``%1$S'', %2$S commands match [%3$S].
msg.err.required.nr.param = Missing %1$S parameters. This alias requires at least %2$S parameters.
msg.err.max.dispatch.depth = Reached max dispatch depth while attempting to dispatch ``%1$S''.
## chatzilla error messages ##
msg.err.invalid.pref = Invalid value for preference %1$S (%2$S).