mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-19 10:29:30 +01:00
Interpreter: split_line is now smarter about JSON and code
This commit is contained in:
parent
3e2395370f
commit
8e21de1f60
@ -550,7 +550,8 @@ sub split_line {
|
|||||||
|
|
||||||
my %default_opts = (
|
my %default_opts = (
|
||||||
strip_quotes => 0,
|
strip_quotes => 0,
|
||||||
keep_spaces => 0
|
keep_spaces => 0,
|
||||||
|
preserve_escapes => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
%opts = (%default_opts, %opts);
|
%opts = (%default_opts, %opts);
|
||||||
@ -591,7 +592,11 @@ sub split_line {
|
|||||||
$spaces = 0 if $ch ne ' ';
|
$spaces = 0 if $ch ne ' ';
|
||||||
|
|
||||||
if ($escaped) {
|
if ($escaped) {
|
||||||
$token .= "\\$ch";
|
if ($opts{preserve_escapes}) {
|
||||||
|
$token .= "\\$ch";
|
||||||
|
} else {
|
||||||
|
$token .= $ch;
|
||||||
|
}
|
||||||
$escaped = 0;
|
$escaped = 0;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
@ -615,7 +620,7 @@ sub split_line {
|
|||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($last_ch eq ' ' and not defined $quote and ($ch eq "'" or $ch eq '"')) {
|
if (($last_ch eq ' ' or $last_ch eq ':' or $last_ch eq '(') and not defined $quote and ($ch eq "'" or $ch eq '"')) {
|
||||||
if ($ignore_quote) {
|
if ($ignore_quote) {
|
||||||
# treat unbalanced quote as part of this argument
|
# treat unbalanced quote as part of this argument
|
||||||
$token .= $ch;
|
$token .= $ch;
|
||||||
|
Loading…
Reference in New Issue
Block a user