Bug 851 - Can't use parameters containing spaces in CLI
: Can't use parameters containing spaces in CLI
Status: RESOLVED INVALID
Product: Logitech Media Server
Classification: Unclassified
Component: CLI
: 5.x or older
: All All
: P3 normal (vote)
: ---
Assigned To: Dan Sully
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-02-24 07:08 UTC by Mike Convey
Modified: 2008-12-18 11:53 UTC (History)
0 users

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Convey 2005-02-24 07:08:11 UTC
This is a particular problem when trying to use the 'display' command after opening a TCP socket to 
port 9090 and e.g. typing
display "hello word" "this is line 2" 30

the CLI just splits on the space, thus creating 7 arguments instead of 3.

From Stdio.pm:

 # todo - allow for escaping and/or quoting
my @params = split(" ", $command);

One fix is to use 'shellwords.pl' - this should come with most perl distributions, or could just be copied 
into Stdio.pm - e.g.
at the top of Stdio.pm:
require 'shellwords.pl';

and replace the split with
my @params = &shellwords($command);


I haven't done any extensive testing of this, and don't know what else it may break.
Comment 1 Dan Sully 2005-02-24 13:55:27 UTC
Mike - I've checked in a fix for this as subversion change #2190
Comment 2 Fred 2005-03-22 02:21:32 UTC
The CLI API expects URL ESCAPED parameters and not shell-like parameters. The
particular example works if sending:

display hello%20world this%20is%20line%202 30

Splitting on spaces AND url escaping work together to enable space in parameters.

Changing this to accept shell like parameters break passing URLs to the CLI
(<item> parameter in many CLI commands). URLs can contain \ and ', that break
the shell-like parsing.

IMHO the CLI is more a machine API than a human command line API. For the
display case, it is trivial to create a simple perl script that does the
transformation. I don't see any other command where a space could be needed in a
parameter, and many commands expect a URL.

I would therefore recommend to close this bug and leave the API as it stands;
human convenient scripting can be easily achieved, such a script is described in
bug 1140.
Comment 3 KDF 2005-03-22 14:53:45 UTC
dan, this is probably your call at this point.  This restriction is noted in the
docs, but perhaps could be reiterated as part of the display command as I
believe this is a more commonly used command for simple scripts, such as ones
that make announcements.
Comment 4 Blackketter Dean 2005-03-23 13:29:00 UTC
Use URL escaping instead of quoting to get spaces, etc...
Comment 5 Chris Owens 2008-12-18 11:53:54 UTC
Routine bug db maintenance; removing old versions which cause confusion.  I apologize for the inconvenience.