3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-29 23:39:24 +01:00

Fix split_line issue where it could sometimes forget tokens when encountering unbalanced quotes

This commit is contained in:
Pragmatic Software 2019-07-08 15:51:55 -07:00
parent 83fc8536d0
commit 81ae3a5741
3 changed files with 9 additions and 3 deletions

View File

@ -572,6 +572,7 @@ sub split_line {
my $escaped = 0;
my $quote;
my $token = '';
my $last_token = '';
my $ch = ' ';
my $last_ch;
my $next_ch;
@ -590,7 +591,7 @@ sub split_line {
$ignore_quote = 1;
$quote = undef;
$last_ch = ' ';
$token = '';
$token = $last_token;
} else {
# add final token and exit
push @args, $token if length $token;
@ -641,6 +642,7 @@ sub split_line {
# begin potential quoted argument
$pos = $i - 1;
$quote = $ch;
$last_token = $token;
$token .= $ch unless $opts{strip_quotes};
}
next;

View File

@ -1040,6 +1040,7 @@ sub split_line {
my $escaped = 0;
my $quote;
my $token = '';
my $last_token = '';
my $ch = ' ';
my $last_ch;
my $next_ch;
@ -1058,7 +1059,7 @@ sub split_line {
$ignore_quote = 1;
$quote = undef;
$last_ch = ' ';
$token = '';
$token = $last_token;
} else {
# add final token and exit
push @args, $token if length $token;
@ -1109,6 +1110,7 @@ sub split_line {
# begin potential quoted argument
$pos = $i - 1;
$quote = $ch;
$last_token = $token;
$token .= $ch unless $opts{strip_quotes};
}
next;

View File

@ -103,6 +103,7 @@ sub split_line {
my $escaped = 0;
my $quote;
my $token = '';
my $last_token = '';
my $ch = ' ';
my $last_ch;
my $next_ch;
@ -121,7 +122,7 @@ sub split_line {
$ignore_quote = 1;
$quote = undef;
$last_ch = ' ';
$token = '';
$token = $last_token;
} else {
# add final token and exit
push @args, $token if length $token;
@ -172,6 +173,7 @@ sub split_line {
# begin potential quoted argument
$pos = $i - 1;
$quote = $ch;
$last_token = $token;
$token .= $ch unless $opts{strip_quotes};
}
next;