Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Commands cannot accept many paths #2148

Closed
MGatner opened this issue Aug 18, 2019 · 6 comments
Closed

Bug: Commands cannot accept many paths #2148

MGatner opened this issue Aug 18, 2019 · 6 comments
Assignees
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Milestone

Comments

@MGatner
Copy link
Member

MGatner commented Aug 18, 2019

Describe the bug
Because CLI commands are actually routed their parameters go through some routing and filtering making it impossible to pass certain characters as a parameter. Of note that I ran into was trying to use a command that take a files path - the "/"s and "-"s cause it to be filtered and never arrives in $params.

CodeIgniter 4 version
Latest develop branch

Affected module(s)
CLI Commands

Expected behavior, and steps to reproduce if appropriate
Create a simple commands that calls var_dump($params) in run(). Call it:
php spark test:command /usr/bin/myfile.txt
Response is empty array.

Context

  • OS: Linux
  • Web server Apache
  • PHP version 7.2+
@jim-parry jim-parry added this to the 4.0.0-rc.2 milestone Sep 8, 2019
@jim-parry
Copy link
Contributor

Have you tried quoting the offending string?
php spark test:command "/usr/bin/myfile.txt"

@jim-parry jim-parry modified the milestones: 4.0.0-rc.2, 4.0.0-rc.3 Sep 24, 2019
@MGatner
Copy link
Member Author

MGatner commented Sep 24, 2019

Yes, it still routes it:

class Test extends BaseCommand
{
    public function run(array $params)
    {
		dd($params);
    }
$ ./spark test "/usr/tmp/bin"

CodeIgniter CLI Tool - Version 4.0.0-rc.1 - Server-Time: 2019-09-24 10:36:06am

│ $params │
array (4) [
    0 => string (0) ""
    1 => string (3) "usr"
    2 => string (3) "tmp"
    3 => string (3) "bin"
]

Called from .../app/Commands/Test.php:14 [App\Commands\Test->run()]

@jim-parry
Copy link
Contributor

Not a bug. Slashes need to be url-encoded, i.e. %2fusr%2ftemp%2fbin
The parameter needs to then be urldecode(...) in your code to see the original string with slashes.

@MGatner
Copy link
Member Author

MGatner commented Oct 15, 2019

Maybe "bug" isn't the correct term, but it's definitely a broken expectation. If I'm sitting at a shell prompt and want to call a command with a file argument I type ./command /path/to/file. For spark to require HTML encoding for paths is pretty weird.

@lonnieezell
Copy link
Member

Agreed, HTML encoding shouldn't be needed here.

@jim-parry jim-parry removed this from the 4.0.0-rc.3 milestone Oct 16, 2019
@jim-parry jim-parry added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 19, 2019
@jim-parry jim-parry added this to the 4.0.0 milestone Oct 29, 2019
@lonnieezell lonnieezell modified the milestones: 4.0.0-rc.4, 4.0.0 Jan 23, 2020
@lonnieezell
Copy link
Member

@MGatner have you had any more chance to look into this?

@MGatner MGatner self-assigned this Feb 17, 2020
@MGatner MGatner mentioned this issue Feb 18, 2020
5 tasks
@MGatner MGatner closed this as completed Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

3 participants