3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-30 07:59:42 +01:00

Factoids: Do not increment depth for skipped expansions

This commit is contained in:
Pragmatic Software 2018-01-21 20:07:33 -08:00
parent 48acc76f2a
commit 951c1280ab

View File

@ -412,12 +412,12 @@ sub expand_factoid_vars {
$action =~ s/\$0/$root_keyword/g; $action =~ s/\$0/$root_keyword/g;
my $const_action = $action; my $const_action = $action;
while ($const_action =~ /(\ba\s*|\ban\s*)?(?<!\\)\$([a-zA-Z0-9_:\-#\[\]]+)/gi) { while ($const_action =~ /(\ba\s*|\ban\s*)?(?<!\\)\$([a-zA-Z0-9_:\-#\[\]]+)/gi) {
last if ++$depth >= 100;
my ($a, $v) = ($1, $2); my ($a, $v) = ($1, $2);
$v =~ s/(.):$/$1/; $v =~ s/(.):$/$1/;
next if $v =~ m/^[\W_]/; # special character prefix skipped for shell/code-factoids/etc next if $v =~ m/^[\W_]/; # special character prefix skipped for shell/code-factoids/etc
next if $v =~ m/^(nick|channel|randomnick|arglen|args|arg\[.+\]|[_0])$/i; # don't override special variables next if $v =~ m/^(nick|channel|randomnick|arglen|args|arg\[.+\]|[_0])$/i; # don't override special variables
next if @exclude && grep { $v =~ m/^\Q$_\E$/i } @exclude; next if @exclude && grep { $v =~ m/^\Q$_\E$/i } @exclude;
last if ++$depth >= 100;
$matches++; $matches++;