Fixed
Details
Assignee
Pothys - MitrahSoftPothys - MitrahSoftReporter
Joseph GoochJoseph GoochPriority
MinorLabels
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
NoneAffects versions
Details
Details
Assignee
Pothys - MitrahSoft
Pothys - MitrahSoftReporter
Joseph Gooch
Joseph GoochPriority
Labels
Fix versions
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Sprint
None
Affects versions
Created 2 October 2018 at 14:43
Updated 4 June 2020 at 09:40
Resolved 3 January 2019 at 17:26
args = [ "my", "set", "of command", "line arguments" ]
cfexecute(name="/bin/echo", arguments=args, timeout=10)
What it tries to execute:
/bin/echo[my, set, of command, line arguments]
Why: see red:
{{
public void setArguments(Object args) {
if(args instanceof lucee.runtime.type.Collection) {
StringBuffer sb=new StringBuffer();
lucee.runtime.type.Collection coll=(lucee.runtime.type.Collection)args;
//lucee.runtime.type.Collection.Key[] keys=coll.keys();
Iterator<Object> it = coll.valueIterator();
while(it.hasNext()) {
sb.append(' ');
sb.append(it.next());
}
arguments=args.toString();
}
else if(args instanceof String) {
arguments=" "+args.toString();
}
else this.arguments="";
}
}}
I would suggest changing args.toString() to sb.toString().... Except I disagree with the entire approach.
The reason one might use arrays instead of a string to pass in arguments is to avoid text parsing issues. If I call Runtime.exec() with an array, then my argument above "of command" or "line arguments" will properly be a SINGLE argument, not two separate ones. Merging the array unceremoniously back into a string with space delimiters removes the context. And doesn't insert any quotes to make underlying layers process it correctly.
Even worse, the underlying lang.commons.cli.Command object accepts arrays! Sooooooo why switch the array, to a string, to be parsed back into an array later?