Skip to content
Permalink
Browse files

regexp: \z replaced with D modifier

  • Loading branch information...
dg committed Jul 11, 2019
1 parent 96d8a7e commit fb054cc6ccc2855320f3c06db0477b67d64deda5
Showing with 8 additions and 8 deletions.
  1. +1 −1 src/Bridges/HttpDI/HttpExtension.php
  2. +5 −5 src/Http/RequestFactory.php
  3. +2 −2 src/Http/Session.php
@@ -140,7 +140,7 @@ private static function buildPolicy(array $config): string
$policy = $policy === true ? [] : (array) $policy;
$value .= $type;
foreach ($policy as $item) {
$value .= !isset($nonQuoted[$type]) && preg_match('#^[a-z-]+\z#', $item) ? " '$item'" : " $item";
$value .= !isset($nonQuoted[$type]) && preg_match('#^[a-z-]+$#D', $item) ? " '$item'" : " $item";
}
$value .= '; ';
}
@@ -26,7 +26,7 @@ class RequestFactory
/** @var array */
public $urlFilters = [
'path' => ['#/{2,}#' => '/'], // '%20' => ''
'url' => [], // '#[.,)]\z#' => ''
'url' => [], // '#[.,)]$#D' => ''
];
/** @var bool */
@@ -91,7 +91,7 @@ private function getServer(Url $url): void
if (
(isset($_SERVER[$tmp = 'HTTP_HOST']) || isset($_SERVER[$tmp = 'SERVER_NAME']))
&& preg_match('#^([a-z0-9_.-]+|\[[a-f0-9:]+\])(:\d+)?\z#i', $_SERVER[$tmp], $pair)
&& preg_match('#^([a-z0-9_.-]+|\[[a-f0-9:]+\])(:\d+)?$#Di', $_SERVER[$tmp], $pair)
) {
$url->setHost(strtolower($pair[1]));
if (isset($pair[2])) {
@@ -147,7 +147,7 @@ private function getGetPostCookie(Url $url): array
$cookies = $useFilter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? [] : $_COOKIE);
// remove invalid characters
$reChars = '#^[' . self::CHARS . ']*+\z#u';
$reChars = '#^[' . self::CHARS . ']*+$#Du';
if (!$this->binary) {
$list = [&$query, &$post, &$cookies];
foreach ($list as $key => &$val) {
@@ -174,7 +174,7 @@ private function getGetPostCookie(Url $url): array
private function getFiles(): array
{
$reChars = '#^[' . self::CHARS . ']*+\z#u';
$reChars = '#^[' . self::CHARS . ']*+$#Du';
$files = [];
$list = [];
foreach ($_FILES ?? [] as $k => $v) {
@@ -246,7 +246,7 @@ private function getMethod(): ?string
$method = $_SERVER['REQUEST_METHOD'] ?? null;
if (
$method === 'POST'
&& preg_match('#^[A-Z]+\z#', $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ?? '')
&& preg_match('#^[A-Z]+$#D', $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ?? '')
) {
$method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'];
}
@@ -85,7 +85,7 @@ public function start(): void
if (!session_id()) { // session is started for first time
$id = $this->request->getCookie(session_name());
$id = is_string($id) && preg_match('#^[0-9a-zA-Z,-]{22,256}\z#i', $id)
$id = is_string($id) && preg_match('#^[0-9a-zA-Z,-]{22,256}$#Di', $id)
? $id
: session_create_id();
session_id($id); // causes resend of a cookie
@@ -235,7 +235,7 @@ public function getId(): string
*/
public function setName(string $name)
{
if (!preg_match('#[^0-9.][^.]*\z#A', $name)) {
if (!preg_match('#[^0-9.][^.]*$#DA', $name)) {
throw new Nette\InvalidArgumentException('Session name cannot contain dot.');
}

0 comments on commit fb054cc

Please sign in to comment.
You can’t perform that action at this time.