Skip to content
Snippets Groups Projects
Commit be5bb7e3 authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

fixed Process.split_quoted_string

Rev: lib/modules/Process.pmod:1.24
parent 8a2e39d0
No related branches found
No related tags found
No related merge requests found
...@@ -34,7 +34,9 @@ string sh_quote(string s) ...@@ -34,7 +34,9 @@ string sh_quote(string s)
array(string) split_quoted_string(string s) array(string) split_quoted_string(string s)
{ {
s=replace(s, ({"\"","'","\\"," "}), ({"\0\"","\0'","\0\\","\0 "})); s=replace(s,
({"\"", "'", "\\", " ", "\t", "\n"}),
({"\0\"","\0'","\0\\","\0 ","\0\t","\0\n"}));
array(string) x=s/"\0"; array(string) x=s/"\0";
array(string) ret=({x[0]}); array(string) ret=({x[0]});
...@@ -44,7 +46,11 @@ array(string) split_quoted_string(string s) ...@@ -44,7 +46,11 @@ array(string) split_quoted_string(string s)
{ {
case '"': case '"':
ret[-1]+=x[e][1..]; ret[-1]+=x[e][1..];
while(x[++e][0]!='"') ret[-1]+=x[e]; while(x[++e][0]!='"')
{
if(strlen(x[e])==1 && x[e][0]=='\\' && x[e+1][0]=='"') e++;
ret[-1]+=x[e];
}
ret[-1]+=x[e][1..]; ret[-1]+=x[e][1..];
break; break;
...@@ -64,7 +70,11 @@ array(string) split_quoted_string(string s) ...@@ -64,7 +70,11 @@ array(string) split_quoted_string(string s)
break; break;
case ' ': case ' ':
if(strlen(x[e]) > 1 || sizeof(x)==e+1 || x[e+1][0]!=' ') case '\t':
case '\n':
while(strlen(x[e])==1 && (<' ','\t','\n'>) [x[e][0]] )
if(++e >= sizeof(x))
return ret;
ret+=({x[e][1..]}); ret+=({x[e][1..]});
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment