Skip to content

Commit e0d48a1

Browse files
authored
Merge pull request #5263 from paulbalandan/filter-sanitize-string
Replace usage of `FILTER_SANITIZE_STRING`
2 parents 5b1060f + ef7d23d commit e0d48a1

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

system/HTTP/CLIRequest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use RuntimeException;
1616

1717
/**
18-
* Class CLIRequest
19-
*
2018
* Represents a request from the command-line. Provides additional
2119
* tools to interact with that request since CLI requests are not
2220
* static like HTTP requests might be.
@@ -172,17 +170,17 @@ protected function parseCommand()
172170
if ($optionValue) {
173171
$optionValue = false;
174172
} else {
175-
$this->segments[] = filter_var($arg, FILTER_SANITIZE_STRING);
173+
$this->segments[] = esc(strip_tags($arg));
176174
}
177175

178176
continue;
179177
}
180178

181-
$arg = filter_var(ltrim($arg, '-'), FILTER_SANITIZE_STRING);
179+
$arg = esc(strip_tags(ltrim($arg, '-')));
182180
$value = null;
183181

184182
if (isset($args[$i + 1]) && mb_strpos($args[$i + 1], '-') !== 0) {
185-
$value = filter_var($args[$i + 1], FILTER_SANITIZE_STRING);
183+
$value = esc(strip_tags($args[$i + 1]));
186184
$optionValue = true;
187185
}
188186

system/HTTP/CURLRequest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
use InvalidArgumentException;
1818

1919
/**
20-
* Class OutgoingRequest
21-
*
22-
* A lightweight HTTP client for sending synchronous HTTP requests
23-
* via cURL.
20+
* A lightweight HTTP client for sending synchronous HTTP requests via cURL.
2421
*/
2522
class CURLRequest extends Request
2623
{
@@ -109,10 +106,7 @@ class CURLRequest extends Request
109106
public function __construct(App $config, URI $uri, ?ResponseInterface $response = null, array $options = [])
110107
{
111108
if (! function_exists('curl_version')) {
112-
// we won't see this during travis-CI
113-
// @codeCoverageIgnoreStart
114-
throw HTTPException::forMissingCurl();
115-
// @codeCoverageIgnoreEnd
109+
throw HTTPException::forMissingCurl(); // @codeCoverageIgnore
116110
}
117111

118112
parent::__construct($config);
@@ -141,7 +135,7 @@ public function request($method, string $url, array $options = []): ResponseInte
141135

142136
$url = $this->prepareURL($url);
143137

144-
$method = filter_var($method, FILTER_SANITIZE_STRING);
138+
$method = esc(strip_tags($method));
145139

146140
$this->send($method, $url);
147141

system/Router/RouteCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use InvalidArgumentException;
2020

2121
/**
22-
* Class RouteCollection
23-
*
2422
* @todo Implement nested resource routing (See CakePHP)
2523
*/
2624
class RouteCollection implements RouteCollectionInterface
@@ -663,10 +661,11 @@ public function resource(string $name, ?array $options = null): RouteCollectionI
663661
// resources are sent to, we need to have a new name
664662
// to store the values in.
665663
$newName = implode('\\', array_map('ucfirst', explode('/', $name)));
664+
666665
// If a new controller is specified, then we replace the
667666
// $name value with the name of the new controller.
668667
if (isset($options['controller'])) {
669-
$newName = ucfirst(filter_var($options['controller'], FILTER_SANITIZE_STRING));
668+
$newName = ucfirst(esc(strip_tags($options['controller'])));
670669
}
671670

672671
// In order to allow customization of allowed id values
@@ -756,10 +755,11 @@ public function presenter(string $name, ?array $options = null): RouteCollection
756755
// resources are sent to, we need to have a new name
757756
// to store the values in.
758757
$newName = implode('\\', array_map('ucfirst', explode('/', $name)));
758+
759759
// If a new controller is specified, then we replace the
760760
// $name value with the name of the new controller.
761761
if (isset($options['controller'])) {
762-
$newName = ucfirst(filter_var($options['controller'], FILTER_SANITIZE_STRING));
762+
$newName = ucfirst(esc(strip_tags($options['controller'])));
763763
}
764764

765765
// In order to allow customization of allowed id values

0 commit comments

Comments
 (0)