Skip to content

Commit ef7d23d

Browse files
committed
Replace usage of FILTER_SANITIZE_STRING
1 parent 4034dc4 commit ef7d23d

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
@@ -16,10 +16,7 @@
1616
use InvalidArgumentException;
1717

1818
/**
19-
* Class OutgoingRequest
20-
*
21-
* A lightweight HTTP client for sending synchronous HTTP requests
22-
* via cURL.
19+
* A lightweight HTTP client for sending synchronous HTTP requests via cURL.
2320
*/
2421
class CURLRequest extends Request
2522
{
@@ -84,10 +81,7 @@ class CURLRequest extends Request
8481
public function __construct(App $config, URI $uri, ?ResponseInterface $response = null, array $options = [])
8582
{
8683
if (! function_exists('curl_version')) {
87-
// we won't see this during travis-CI
88-
// @codeCoverageIgnoreStart
89-
throw HTTPException::forMissingCurl();
90-
// @codeCoverageIgnoreEnd
84+
throw HTTPException::forMissingCurl(); // @codeCoverageIgnore
9185
}
9286

9387
parent::__construct($config);
@@ -110,7 +104,7 @@ public function request($method, string $url, array $options = []): ResponseInte
110104

111105
$url = $this->prepareURL($url);
112106

113-
$method = filter_var($method, FILTER_SANITIZE_STRING);
107+
$method = esc(strip_tags($method));
114108

115109
$this->send($method, $url);
116110

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)