Repository: codeigniter4/CodeIgniter4 (PHP)

Issue:
Bug: CLI command can't get param data properly
**Describe the bug**
- When controllers run via CLI, they can't get param data properly
- CLI commands can't get param data properly

e.g.
- input `abc < def` → param `abc `
- input `McDonald's` → param `McDonald&#39;s`
- input `
aaa
` → param `aaa`

Related #5263

**CodeIgniter 4 version**
`develop` after 4.1.4

**Affected module(s)**
CLIRequest

**Expected behavior, and steps to reproduce if appropriate**

### Controller

```php
<?php
namespace App\Controllers;
use CodeIgniter\Controller;
class Test extends Controller
{
    public function run($param = '')
    {
        var_dump($param);
    }
}
```

```sh-session
$ php public/index.php test run 'abc < def'
string(4) "abc "
```
```sh-session
$ php public/index.php test run "McDonald's"
string(14) "McDonald&#39;s"
```
```sh-session
$ php public/index.php test run '
aaa
'
string(3) "aaa"
```

### Command

```php
<?php
namespace App\Commands;
use CodeIgniter\CLI\BaseCommand;
class Test extends BaseCommand
{
    protected $group       = 'tests';
    protected $name        = 'test';
    protected $description = 'Just testing.';

    public function run(array $params)
    {
        var_dump($params);
    }
}
```

```sh-session
$ php spark test 'abc < def'

CodeIgniter v4.1.4 Command Line Tool - Server Time: 2021-10-31 21:15:20 UTC-05:00

array(1) {
  [0] =>
  string(4) "abc "
}
```
```sh-session
$ php spark test "McDonald's"

CodeIgniter v4.1.4 Command Line Tool - Server Time: 2021-10-31 21:15:30 UTC-05:00

array(1) {
  [0] =>
  string(14) "McDonald&#39;s"
}
```
```sh-session
$ php spark test '
aaa
'

CodeIgniter v4.1.4 Command Line Tool - Server Time: 2021-10-31 21:15:39 UTC-05:00

array(1) {
  [0] =>
  string(3) "aaa"
}
```

**Context**
- OS: [macOS 10.15.7]
- Web server [n/a]
- PHP version [8.0.12]
- Database: [n/a]



Discussion:

Patch:
diff --git a/system/HTTP/CLIRequest.php b/system/HTTP/CLIRequest.php
index fcc2a51389d2..b10d41884733 100644
--- a/system/HTTP/CLIRequest.php
+++ b/system/HTTP/CLIRequest.php
@@ -170,17 +170,17 @@ protected function parseCommand()
                 if ($optionValue) {
                     $optionValue = false;
                 } else {
-                    $this->segments[] = esc(strip_tags($arg));
+                    $this->segments[] = $arg;
                 }
 
                 continue;
             }
 
-            $arg   = esc(strip_tags(ltrim($arg, '-')));
+            $arg   = ltrim($arg, '-');
             $value = null;
 
             if (isset($args[$i + 1]) && mb_strpos($args[$i + 1], '-') !== 0) {
-                $value       = esc(strip_tags($args[$i + 1]));
+                $value       = $args[$i + 1];
                 $optionValue = true;
             }
 


Test patch:
diff --git a/tests/system/HTTP/CLIRequestTest.php b/tests/system/HTTP/CLIRequestTest.php
index c31bace6b554..1c7c23c1c21e 100644
--- a/tests/system/HTTP/CLIRequestTest.php
+++ b/tests/system/HTTP/CLIRequestTest.php
@@ -61,6 +61,30 @@ public function testParsingSegments()
         $this->assertSame($segments, $this->request->getSegments());
     }
 
+    public function testParsingSegmentsWithHTMLMetaChars()
+    {
+        $_SERVER['argv'] = [
+            'index.php',
+            'users',
+            '21',
+            'abc < def',
+            "McDonald's",
+            '
aaa
',
+        ];
+
+        // reinstantiate it to force parsing
+        $this->request = new CLIRequest(new App());
+
+        $segments = [
+            'users',
+            '21',
+            'abc < def',
+            "McDonald's",
+            '
aaa
',
+        ];
+        $this->assertSame($segments, $this->request->getSegments());
+    }
+
     public function testParsingOptions()
     {
         $_SERVER['argv'] = [