From eab2f019395c8f0dc91d386aa1f5e82b38c49165 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 7 Mar 2022 14:48:58 +0100 Subject: [PATCH] private constants are PascalCase --- src/Http/RequestFactory.php | 8 ++++---- src/Http/Session.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Http/RequestFactory.php b/src/Http/RequestFactory.php index f02047aa..fe406289 100644 --- a/src/Http/RequestFactory.php +++ b/src/Http/RequestFactory.php @@ -21,7 +21,7 @@ class RequestFactory use Nette\SmartObject; /** @internal */ - private const CHARS = '\x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF}'; + private const ValidChars = '\x09\x0A\x0D\x20-\x7E\xA0-\x{10FFFF}'; /** @var array */ public $urlFilters = [ @@ -156,7 +156,7 @@ private function getGetPostCookie(Url $url): array : (empty($_COOKIE) ? [] : $_COOKIE); // remove invalid characters - $reChars = '#^[' . self::CHARS . ']*+$#Du'; + $reChars = '#^[' . self::ValidChars . ']*+$#Du'; if (!$this->binary) { $list = [&$query, &$post, &$cookies]; foreach ($list as $key => &$val) { @@ -169,7 +169,7 @@ private function getGetPostCookie(Url $url): array $list[] = &$list[$key][$k]; } elseif (is_string($v)) { - $list[$key][$k] = (string) preg_replace('#[^' . self::CHARS . ']+#u', '', $v); + $list[$key][$k] = (string) preg_replace('#[^' . self::ValidChars . ']+#u', '', $v); } else { throw new Nette\InvalidStateException(sprintf('Invalid value in $_POST/$_COOKIE in key %s, expected string, %s given.', "'$k'", gettype($v))); @@ -187,7 +187,7 @@ private function getGetPostCookie(Url $url): array private function getFiles(): array { - $reChars = '#^[' . self::CHARS . ']*+$#Du'; + $reChars = '#^[' . self::ValidChars . ']*+$#Du'; $files = []; $list = []; foreach ($_FILES ?? [] as $k => $v) { diff --git a/src/Http/Session.php b/src/Http/Session.php index fdbc9985..87536242 100644 --- a/src/Http/Session.php +++ b/src/Http/Session.php @@ -20,9 +20,9 @@ class Session use Nette\SmartObject; /** Default file lifetime */ - private const DEFAULT_FILE_LIFETIME = 3 * Nette\Utils\DateTime::HOUR; + private const DefaultFileLifetime = 3 * Nette\Utils\DateTime::HOUR; - private const SECURITY_OPTIONS = [ + private const SecurityOptions = [ 'referer_check' => '', // must be disabled because PHP implementation is invalid 'use_cookies' => 1, // must be enabled to prevent Session Hijacking and Fixation 'use_only_cookies' => 1, // must be enabled to prevent Session Fixation @@ -47,7 +47,7 @@ class Session private $options = [ 'cookie_samesite' => IResponse::SAME_SITE_LAX, 'cookie_lifetime' => 0, // for a maximum of 3 hours or until the browser is closed - 'gc_maxlifetime' => self::DEFAULT_FILE_LIFETIME, // 3 hours + 'gc_maxlifetime' => self::DefaultFileLifetime, // 3 hours ]; /** @var IRequest */ @@ -93,14 +93,14 @@ private function doStart($mustExists = false): void { if (session_status() === PHP_SESSION_ACTIVE) { // adapt an existing session if (!$this->started) { - $this->configure(self::SECURITY_OPTIONS); + $this->configure(self::SecurityOptions); $this->initialize(); } return; } - $this->configure(self::SECURITY_OPTIONS + $this->options); + $this->configure(self::SecurityOptions + $this->options); if (!session_id()) { // session is started for first time $id = $this->request->getCookie(session_name()); @@ -500,7 +500,7 @@ public function setExpiration(?string $time) { if ($time === null) { return $this->setOptions([ - 'gc_maxlifetime' => self::DEFAULT_FILE_LIFETIME, + 'gc_maxlifetime' => self::DefaultFileLifetime, 'cookie_lifetime' => 0, ]);