From be5bb7e39f73fc66a707b532beadd766e21edf09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Tue, 11 Jul 2000 13:42:22 -0700 Subject: [PATCH] fixed Process.split_quoted_string Rev: lib/modules/Process.pmod:1.24 --- lib/modules/Process.pmod | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/modules/Process.pmod b/lib/modules/Process.pmod index af9648c6a8..886d263357 100644 --- a/lib/modules/Process.pmod +++ b/lib/modules/Process.pmod @@ -34,7 +34,9 @@ string sh_quote(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) ret=({x[0]}); @@ -44,7 +46,11 @@ array(string) split_quoted_string(string s) { case '"': 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..]; break; @@ -64,8 +70,12 @@ array(string) split_quoted_string(string s) break; case ' ': - if(strlen(x[e]) > 1 || sizeof(x)==e+1 || x[e+1][0]!=' ') - ret+=({x[e][1..]}); + case '\t': + case '\n': + while(strlen(x[e])==1 && (<' ','\t','\n'>) [x[e][0]] ) + if(++e >= sizeof(x)) + return ret; + ret+=({x[e][1..]}); break; default: -- GitLab