CFEXECUTE arguments does not properly handle arrays

Description

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?

Environment

Linux, but N/A

Attachments

1
  • 03 Oct 2018, 01:41 pm

Activity

Show:

Michael Offner 3 January 2019 at 16:44

completely rewritten how it works and solved a problem with joining when no timeout is set

Joseph Gooch 3 December 2018 at 18:58

@micha please refer to PR #614

Specifically, when a string is passed, you’re never parsing the result into
multiple arguments (you’re doing list.add(Caster.toString(args.toString()))
which means the entire arguments attribute will be ONE argument)

On Mon, Dec 3, 2018 at 5:58 AM Michael Offner (JIRA) <

Pothys - MitrahSoft 28 November 2018 at 11:18

Added the fix for this issue.

Pull Request : https://github.com/lucee/Lucee/pull/612

Fixed

Details

Assignee

Reporter

Priority

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

Affects versions

Created 2 October 2018 at 14:43
Updated 4 June 2020 at 09:40
Resolved 3 January 2019 at 17:26

Flag notifications