From 69c081fd9a0ed4f1f7909d0ae01a61cd570ce053 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 12 Nov 2017 08:04:42 -0800 Subject: [PATCH] Limit maximum number of factoid variable expansions --- PBot/Factoids.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PBot/Factoids.pm b/PBot/Factoids.pm index 9ba5dec5..e8bbfc20 100644 --- a/PBot/Factoids.pm +++ b/PBot/Factoids.pm @@ -403,11 +403,12 @@ sub expand_factoid_vars { my $depth = 0; while (1) { - last if ++$depth >= 10; + last if ++$depth >= 20; my $matches = 0; $action =~ s/\$0/$root_keyword/g; my $const_action = $action; while ($const_action =~ /(\ba\s*|\ban\s*)?(?= 20; my ($a, $v) = ($1, $2); $v =~ s/(.):$/$1/; 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; + my $depth = 0; my $const_action = $action; while ($const_action =~ m/\$arg\[([^]]+)]/g) { my $arg = $1; + last if ++$depth >= 20; + if ($arg eq '*') { if (not defined $input or $input eq '') { $action =~ s/\$arg\[\*\]/$nick/;