Skip to content

Commit fe2c565

Browse files
committed
fix: remove incorrect processing of CLI params
Fixes #5266
1 parent fab038d commit fe2c565

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

system/HTTP/CLIRequest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,17 @@ protected function parseCommand()
170170
if ($optionValue) {
171171
$optionValue = false;
172172
} else {
173-
$this->segments[] = esc(strip_tags($arg));
173+
$this->segments[] = $arg;
174174
}
175175

176176
continue;
177177
}
178178

179-
$arg = esc(strip_tags(ltrim($arg, '-')));
179+
$arg = ltrim($arg, '-');
180180
$value = null;
181181

182182
if (isset($args[$i + 1]) && mb_strpos($args[$i + 1], '-') !== 0) {
183-
$value = esc(strip_tags($args[$i + 1]));
183+
$value = $args[$i + 1];
184184
$optionValue = true;
185185
}
186186

tests/system/HTTP/CLIRequestTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,30 @@ public function testParsingSegments()
6161
$this->assertSame($segments, $this->request->getSegments());
6262
}
6363

64+
public function testParsingSegmentsWithHTMLMetaChars()
65+
{
66+
$_SERVER['argv'] = [
67+
'index.php',
68+
'users',
69+
'21',
70+
'abc < def',
71+
"McDonald's",
72+
'<s>aaa</s>',
73+
];
74+
75+
// reinstantiate it to force parsing
76+
$this->request = new CLIRequest(new App());
77+
78+
$segments = [
79+
'users',
80+
'21',
81+
'abc < def',
82+
"McDonald's",
83+
'<s>aaa</s>',
84+
];
85+
$this->assertSame($segments, $this->request->getSegments());
86+
}
87+
6488
public function testParsingOptions()
6589
{
6690
$_SERVER['argv'] = [

0 commit comments

Comments
 (0)