mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 12:12:34 +01:00
Limit maximum number of factoid variable expansions
This commit is contained in:
parent
9acb38d790
commit
69c081fd9a
@ -403,11 +403,12 @@ sub expand_factoid_vars {
|
|||||||
|
|
||||||
my $depth = 0;
|
my $depth = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
last if ++$depth >= 10;
|
last if ++$depth >= 20;
|
||||||
my $matches = 0;
|
my $matches = 0;
|
||||||
$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 >= 20;
|
||||||
my ($a, $v) = ($1, $2);
|
my ($a, $v) = ($1, $2);
|
||||||
$v =~ s/(.):$/$1/;
|
$v =~ s/(.):$/$1/;
|
||||||
next if $v =~ m/^_/; # underscore-prefixed vars reserved for code-factoids
|
next if $v =~ m/^_/; # underscore-prefixed vars reserved for code-factoids
|
||||||
@ -520,10 +521,13 @@ sub expand_action_arguments {
|
|||||||
|
|
||||||
$action =~ s/\$arglen\b/scalar @args/eg;
|
$action =~ s/\$arglen\b/scalar @args/eg;
|
||||||
|
|
||||||
|
my $depth = 0;
|
||||||
my $const_action = $action;
|
my $const_action = $action;
|
||||||
while ($const_action =~ m/\$arg\[([^]]+)]/g) {
|
while ($const_action =~ m/\$arg\[([^]]+)]/g) {
|
||||||
my $arg = $1;
|
my $arg = $1;
|
||||||
|
|
||||||
|
last if ++$depth >= 20;
|
||||||
|
|
||||||
if ($arg eq '*') {
|
if ($arg eq '*') {
|
||||||
if (not defined $input or $input eq '') {
|
if (not defined $input or $input eq '') {
|
||||||
$action =~ s/\$arg\[\*\]/$nick/;
|
$action =~ s/\$arg\[\*\]/$nick/;
|
||||||
|
Loading…
Reference in New Issue
Block a user