mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
Interpreter: disregard quotes in extract_bracketed; replace ;; with ;;;
This commit is contained in:
parent
be528094b6
commit
5f2276bf63
@ -224,7 +224,7 @@ sub interpret {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# check for splitted commands
|
# check for splitted commands
|
||||||
if ($stuff->{command} =~ m/^(.*?)\s*(?<!\\);;\s*(.*)/ms) {
|
if ($stuff->{command} =~ m/^(.*?)\s*(?<!\\);;;\s*(.*)/ms) {
|
||||||
$stuff->{command} = $1;
|
$stuff->{command} = $1;
|
||||||
$stuff->{command_split} = $2;
|
$stuff->{command_split} = $2;
|
||||||
}
|
}
|
||||||
@ -325,7 +325,7 @@ sub interpret {
|
|||||||
$stuff->{original_arguments} = $arguments;
|
$stuff->{original_arguments} = $arguments;
|
||||||
|
|
||||||
# unescape any escaped command splits
|
# unescape any escaped command splits
|
||||||
$arguments =~ s/\\;;/;;/g if defined $arguments;
|
$arguments =~ s/\\;;;/;;;/g if defined $arguments;
|
||||||
|
|
||||||
# unescape any escaped substituted commands
|
# unescape any escaped substituted commands
|
||||||
$arguments =~ s/\\&\s*\{/&{/g if defined $arguments;
|
$arguments =~ s/\\&\s*\{/&{/g if defined $arguments;
|
||||||
@ -384,15 +384,12 @@ sub extract_bracketed {
|
|||||||
my $extracting = 0;
|
my $extracting = 0;
|
||||||
my $extracted = 0;
|
my $extracted = 0;
|
||||||
my $escaped = 0;
|
my $escaped = 0;
|
||||||
my $quote;
|
|
||||||
my $token = '';
|
my $token = '';
|
||||||
my $ch = ' ';
|
my $ch = ' ';
|
||||||
my $last_ch;
|
my $last_ch;
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
my $quote_pos;
|
|
||||||
my $bracket_pos;
|
my $bracket_pos;
|
||||||
my $bracket_level = 0;
|
my $bracket_level = 0;
|
||||||
my $ignore_quote = 0;
|
|
||||||
my $prefix_group_match = @prefix_group ? 0 : 1;
|
my $prefix_group_match = @prefix_group ? 0 : 1;
|
||||||
my $prefix_match = @prefixes ? 0 : 1;
|
my $prefix_match = @prefixes ? 0 : 1;
|
||||||
my $match = 0;
|
my $match = 0;
|
||||||
@ -405,14 +402,7 @@ sub extract_bracketed {
|
|||||||
$last_ch = $ch;
|
$last_ch = $ch;
|
||||||
|
|
||||||
if ($i >= @chars) {
|
if ($i >= @chars) {
|
||||||
if (defined $quote) {
|
if ($extracting) {
|
||||||
# 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) {
|
|
||||||
# reached end, but unbalanced brackets... reset to beginning and ignore them
|
# reached end, but unbalanced brackets... reset to beginning and ignore them
|
||||||
$i = $bracket_pos;
|
$i = $bracket_pos;
|
||||||
$bracket_level = 0;
|
$bracket_level = 0;
|
||||||
@ -441,35 +431,6 @@ sub extract_bracketed {
|
|||||||
next;
|
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 (not $extracted) {
|
||||||
if ($state eq 'prefixgroup' and @prefix_group and not $extracting) {
|
if ($state eq 'prefixgroup' and @prefix_group and not $extracting) {
|
||||||
foreach my $prefix_ch (@prefix_group) {
|
foreach my $prefix_ch (@prefix_group) {
|
||||||
|
Loading…
Reference in New Issue
Block a user