Bugfix: sieve undefined args[i-1]

This commit is contained in:
the-djmaze 2022-05-17 14:48:38 +02:00
parent e6ea47e75f
commit 882c0bde42
8 changed files with 17 additions and 17 deletions

View file

@ -32,7 +32,7 @@ export class ConditionalCommand extends ControlCommand
public function pushArguments(array $args): void
{
args.forEach((arg, i) => {
if (':' === args[i-1][0]) {
if (i && ':' === args[i-1][0]) {
this[args[i-1].replace(':','_')].value = arg.value;
}
});

View file

@ -88,7 +88,7 @@ export class AddressTest extends TestCommand
this.mime = true;
} else if (':anychild' === arg) {
this.anychild = true;
} else if (':index' === args[i-1]) {
} else if (i && ':index' === args[i-1]) {
this.index.value = arg.value;
}
});
@ -205,7 +205,7 @@ export class ExistsTest extends TestCommand
if (':mime' === arg) {
this.mime = true;
} else if (':anychild' === arg) {
this.mime = true;
this.anychild = true;
}
});
}
@ -294,7 +294,7 @@ export class HeaderTest extends TestCommand
this.address_part = arg;
} else if (':last' === arg) {
this.last = true;
} else if (':index' === args[i-1]) {
} else if (i && ':index' === args[i-1]) {
this.index.value = arg.value;
}
});

View file

@ -34,7 +34,7 @@ export class BodyTest extends TestCommand
if (':raw' === arg || ':text' === arg) {
this.body_transform = arg;
} else if (arg instanceof GrammarStringList || arg instanceof GrammarString) {
if (':content' === args[i-1]) {
if (i && ':content' === args[i-1]) {
this.body_transform = ':content ' + arg;
} else {
this[args[i+1] ? 'content_list' : 'key_list'] = arg;

View file

@ -77,9 +77,9 @@ export class VacationCommand extends ActionCommand
args.forEach((arg, i) => {
if (':mime' === arg) {
this.mime = true;
} else if (':addresses' === args[i-1]) {
} else if (i && ':addresses' === args[i-1]) {
this.addresses = arg; // GrammarStringList
} else if (':' === args[i-1][0]) {
} else if (i && ':' === args[i-1][0]) {
// :days, :seconds, :subject, :from, :handle
this[args[i-1].replace(':','_')].value = arg.value;
}

View file

@ -49,9 +49,9 @@ export class DateTest extends TestCommand
this.originalzone = true;
} else if (':last' === arg) {
this.last = true;
} else if (':zone' === args[i-1]) {
} else if (i && ':zone' === args[i-1]) {
this.zone.value = arg.value;
} else if (':index' === args[i-1]) {
} else if (i && ':index' === args[i-1]) {
this.index.value = arg.value;
}
});
@ -85,7 +85,7 @@ export class CurrentDateTest extends TestCommand
this.key_list = args.pop();
this.date_part = args.pop();
args.forEach((arg, i) => {
if (':zone' === args[i-1]) {
if (i && ':zone' === args[i-1]) {
this.zone.value = arg.value;
}
});

View file

@ -69,13 +69,13 @@ export class DeleteHeaderCommand extends ActionCommand
args.forEach((arg, i) => {
if (':last' === arg) {
this.last = true;
} else if (':index' === args[i-1]) {
} else if (i && ':index' === args[i-1]) {
this.index.value = arg.value;
args[i] = null;
}
});
if (args[l-1] instanceof GrammarString) {
if (l && args[l-1] instanceof GrammarString) {
this.field_name = args[l-1];
this.value_patterns = args[l];
} else {

View file

@ -59,9 +59,9 @@ export class NotifyCommand extends ActionCommand
{
this._method.value = args.pop().value; // GrammarQuotedString
args.forEach((arg, i) => {
if (':options' === args[i-1]) {
if (i && ':options' === args[i-1]) {
this.options = arg; // GrammarStringList
} else if (':' === args[i-1][0]) {
} else if (i && ':' === args[i-1][0]) {
// :from, :importance, :message
this[args[i-1].replace(':','_')].value = arg.value;
}

View file

@ -93,7 +93,7 @@ export class ReplaceCommand extends ActionCommand
args.forEach((arg, i) => {
if (':mime' === arg) {
this.mime = true;
} else if (':' === args[i-1][0]) {
} else if (i && ':' === args[i-1][0]) {
// :subject, :from
this[args[i-1].replace(':','_')].value = arg.value;
}
@ -130,7 +130,7 @@ export class EncloseCommand extends ActionCommand
pushArguments(args)
{
args.forEach((arg, i) => {
if (':' === args[i-1][0]) {
if (i && ':' === args[i-1][0]) {
// :subject, :headers
this[args[i-1].replace(':','_')].value = arg.value;
}
@ -170,7 +170,7 @@ export class ExtractTextCommand extends ActionCommand
args.includes(modifier) && this.modifiers.push(modifier);
});
args.forEach((arg, i) => {
if (':' === args[i-1][0]) {
if (i && ':' === args[i-1][0]) {
// :first
this[args[i-1].replace(':','_')].value = arg.value;
}