diff --git a/modules/compiler_vm/languages/_default.pm b/modules/compiler_vm/languages/_default.pm index 88ff7f06..374777b1 100755 --- a/modules/compiler_vm/languages/_default.pm +++ b/modules/compiler_vm/languages/_default.pm @@ -317,8 +317,8 @@ sub execute { $stdin =~ s/(?pretty_format($self->{code}); @@ -1019,9 +1019,11 @@ sub process_interactive_edit { $self->{code} = $code; } -# splits line into quoted arguments while preserving quotes. handles -# unbalanced quotes gracefully by treating them as part of the argument -# they were found within. +# splits line into quoted arguments while preserving quotes. +# a string is considered quoted only if they are surrounded by +# whitespace or json separators. +# handles unbalanced quotes gracefully by treating them as +# part of the argument they were found within. sub split_line { my ($self, $line, %opts) = @_; @@ -1041,6 +1043,7 @@ sub split_line { my $token = ''; my $ch = ' '; my $last_ch; + my $next_ch; my $i = 0; my $pos; my $ignore_quote = 0; @@ -1065,6 +1068,7 @@ sub split_line { } $ch = $chars[$i++]; + $next_ch = $chars[$i]; $spaces = 0 if $ch ne ' '; @@ -1084,7 +1088,7 @@ sub split_line { } if (defined $quote) { - if ($ch eq $quote) { + if ($ch eq $quote and (not defined $next_ch or $next_ch =~ /[\s,:;})\].+=]/)) { # closing quote $token .= $ch unless $opts{strip_quotes}; push @args, $token; @@ -1097,7 +1101,7 @@ sub split_line { next; } - if (($last_ch eq ' ' or $last_ch eq ':' or $last_ch eq '(') and not defined $quote and ($ch eq "'" or $ch eq '"')) { + if (($last_ch =~ /[\s:{(\[.+=]/) and not defined $quote and ($ch eq "'" or $ch eq '"')) { if ($ignore_quote) { # treat unbalanced quote as part of this argument $token .= $ch; diff --git a/modules/compiler_vm/languages/server/_default.pm b/modules/compiler_vm/languages/server/_default.pm index f57df31f..83a560c2 100755 --- a/modules/compiler_vm/languages/server/_default.pm +++ b/modules/compiler_vm/languages/server/_default.pm @@ -81,9 +81,11 @@ sub execute { return ($exitval, $stdout, $stderr); } -# splits line into quoted arguments while preserving quotes. handles -# unbalanced quotes gracefully by treating them as part of the argument -# they were found within. +# splits line into quoted arguments while preserving quotes. +# a string is considered quoted only if they are surrounded by +# whitespace or json separators. +# handles unbalanced quotes gracefully by treating them as +# part of the argument they were found within. sub split_line { my ($self, $line, %opts) = @_; @@ -103,6 +105,7 @@ sub split_line { my $token = ''; my $ch = ' '; my $last_ch; + my $next_ch; my $i = 0; my $pos; my $ignore_quote = 0; @@ -127,6 +130,7 @@ sub split_line { } $ch = $chars[$i++]; + $next_ch = $chars[$i]; $spaces = 0 if $ch ne ' '; @@ -146,7 +150,7 @@ sub split_line { } if (defined $quote) { - if ($ch eq $quote) { + if ($ch eq $quote and (not defined $next_ch or $next_ch =~ /[\s,:;})\].+=]/)) { # closing quote $token .= $ch unless $opts{strip_quotes}; push @args, $token; @@ -159,7 +163,7 @@ sub split_line { next; } - if (($last_ch eq ' ' or $last_ch eq ':' or $last_ch eq '(') and not defined $quote and ($ch eq "'" or $ch eq '"')) { + if (($last_ch =~ /[\s:{(\[.+=]/) and not defined $quote and ($ch eq "'" or $ch eq '"')) { if ($ignore_quote) { # treat unbalanced quote as part of this argument $token .= $ch;