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:
parent
83fc8536d0
commit
81ae3a5741
@ -572,6 +572,7 @@ sub split_line {
|
|||||||
my $escaped = 0;
|
my $escaped = 0;
|
||||||
my $quote;
|
my $quote;
|
||||||
my $token = '';
|
my $token = '';
|
||||||
|
my $last_token = '';
|
||||||
my $ch = ' ';
|
my $ch = ' ';
|
||||||
my $last_ch;
|
my $last_ch;
|
||||||
my $next_ch;
|
my $next_ch;
|
||||||
@ -590,7 +591,7 @@ sub split_line {
|
|||||||
$ignore_quote = 1;
|
$ignore_quote = 1;
|
||||||
$quote = undef;
|
$quote = undef;
|
||||||
$last_ch = ' ';
|
$last_ch = ' ';
|
||||||
$token = '';
|
$token = $last_token;
|
||||||
} else {
|
} else {
|
||||||
# add final token and exit
|
# add final token and exit
|
||||||
push @args, $token if length $token;
|
push @args, $token if length $token;
|
||||||
@ -641,6 +642,7 @@ sub split_line {
|
|||||||
# begin potential quoted argument
|
# begin potential quoted argument
|
||||||
$pos = $i - 1;
|
$pos = $i - 1;
|
||||||
$quote = $ch;
|
$quote = $ch;
|
||||||
|
$last_token = $token;
|
||||||
$token .= $ch unless $opts{strip_quotes};
|
$token .= $ch unless $opts{strip_quotes};
|
||||||
}
|
}
|
||||||
next;
|
next;
|
||||||
|
@ -1040,6 +1040,7 @@ sub split_line {
|
|||||||
my $escaped = 0;
|
my $escaped = 0;
|
||||||
my $quote;
|
my $quote;
|
||||||
my $token = '';
|
my $token = '';
|
||||||
|
my $last_token = '';
|
||||||
my $ch = ' ';
|
my $ch = ' ';
|
||||||
my $last_ch;
|
my $last_ch;
|
||||||
my $next_ch;
|
my $next_ch;
|
||||||
@ -1058,7 +1059,7 @@ sub split_line {
|
|||||||
$ignore_quote = 1;
|
$ignore_quote = 1;
|
||||||
$quote = undef;
|
$quote = undef;
|
||||||
$last_ch = ' ';
|
$last_ch = ' ';
|
||||||
$token = '';
|
$token = $last_token;
|
||||||
} else {
|
} else {
|
||||||
# add final token and exit
|
# add final token and exit
|
||||||
push @args, $token if length $token;
|
push @args, $token if length $token;
|
||||||
@ -1109,6 +1110,7 @@ sub split_line {
|
|||||||
# begin potential quoted argument
|
# begin potential quoted argument
|
||||||
$pos = $i - 1;
|
$pos = $i - 1;
|
||||||
$quote = $ch;
|
$quote = $ch;
|
||||||
|
$last_token = $token;
|
||||||
$token .= $ch unless $opts{strip_quotes};
|
$token .= $ch unless $opts{strip_quotes};
|
||||||
}
|
}
|
||||||
next;
|
next;
|
||||||
|
@ -103,6 +103,7 @@ sub split_line {
|
|||||||
my $escaped = 0;
|
my $escaped = 0;
|
||||||
my $quote;
|
my $quote;
|
||||||
my $token = '';
|
my $token = '';
|
||||||
|
my $last_token = '';
|
||||||
my $ch = ' ';
|
my $ch = ' ';
|
||||||
my $last_ch;
|
my $last_ch;
|
||||||
my $next_ch;
|
my $next_ch;
|
||||||
@ -121,7 +122,7 @@ sub split_line {
|
|||||||
$ignore_quote = 1;
|
$ignore_quote = 1;
|
||||||
$quote = undef;
|
$quote = undef;
|
||||||
$last_ch = ' ';
|
$last_ch = ' ';
|
||||||
$token = '';
|
$token = $last_token;
|
||||||
} else {
|
} else {
|
||||||
# add final token and exit
|
# add final token and exit
|
||||||
push @args, $token if length $token;
|
push @args, $token if length $token;
|
||||||
@ -172,6 +173,7 @@ sub split_line {
|
|||||||
# begin potential quoted argument
|
# begin potential quoted argument
|
||||||
$pos = $i - 1;
|
$pos = $i - 1;
|
||||||
$quote = $ch;
|
$quote = $ch;
|
||||||
|
$last_token = $token;
|
||||||
$token .= $ch unless $opts{strip_quotes};
|
$token .= $ch unless $opts{strip_quotes};
|
||||||
}
|
}
|
||||||
next;
|
next;
|
||||||
|
Loading…
Reference in New Issue
Block a user