From 5f2276bf639662b335384b14973da3bf8215c2c9 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 23 Aug 2019 14:07:21 -0700 Subject: [PATCH] Interpreter: disregard quotes in extract_bracketed; replace ;; with ;;; --- PBot/Interpreter.pm | 45 +++------------------------------------------ 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/PBot/Interpreter.pm b/PBot/Interpreter.pm index 9d60e515..3a552019 100644 --- a/PBot/Interpreter.pm +++ b/PBot/Interpreter.pm @@ -224,7 +224,7 @@ sub interpret { } # check for splitted commands - if ($stuff->{command} =~ m/^(.*?)\s*(?{command} =~ m/^(.*?)\s*(?{command} = $1; $stuff->{command_split} = $2; } @@ -325,7 +325,7 @@ sub interpret { $stuff->{original_arguments} = $arguments; # unescape any escaped command splits - $arguments =~ s/\\;;/;;/g if defined $arguments; + $arguments =~ s/\\;;;/;;;/g if defined $arguments; # unescape any escaped substituted commands $arguments =~ s/\\&\s*\{/&{/g if defined $arguments; @@ -384,15 +384,12 @@ sub extract_bracketed { my $extracting = 0; my $extracted = 0; my $escaped = 0; - my $quote; my $token = ''; my $ch = ' '; my $last_ch; my $i = 0; - my $quote_pos; my $bracket_pos; my $bracket_level = 0; - my $ignore_quote = 0; my $prefix_group_match = @prefix_group ? 0 : 1; my $prefix_match = @prefixes ? 0 : 1; my $match = 0; @@ -405,14 +402,7 @@ sub extract_bracketed { $last_ch = $ch; if ($i >= @chars) { - if (defined $quote) { - # reached end, but unbalanced quote... reset to beginning of quote and ignore it - $i = $quote_pos; - $ignore_quote = 1; - $quote = undef; - $last_ch = ' '; - $token = ''; - } elsif ($extracting) { + if ($extracting) { # reached end, but unbalanced brackets... reset to beginning and ignore them $i = $bracket_pos; $bracket_level = 0; @@ -441,35 +431,6 @@ sub extract_bracketed { next; } - if (defined $quote) { - if ($ch eq $quote) { - # closing quote - $token .= $ch if $extracting or $extracted; - $result .= $token if $extracting; - $rest .= $token if $extracted; - $quote = undef; - $token = ''; - } else { - # still within quoted argument - $token .= $ch if $extracting or $extracted; - } - next; - } - - if ($last_ch eq ' ' and not defined $quote and ($ch eq "'" or $ch eq '"')) { - if ($ignore_quote) { - # treat unbalanced quote as part of this argument - $token .= $ch if $extracting or $extracted; - $ignore_quote = 0; - } else { - # begin potential quoted argument - $quote_pos = $i - 1; - $quote = $ch; - $token .= $ch if $extracting or $extracted; - } - next; - } - if (not $extracted) { if ($state eq 'prefixgroup' and @prefix_group and not $extracting) { foreach my $prefix_ch (@prefix_group) {