From 228289b7bd286fe04f7193ad47055f9f03bc8254 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 17 Jun 2020 00:19:45 +0200 Subject: [PATCH 01/22] opened 3.1-dev --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d193eab3..6f681437 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } } } From 9fd6714ce48b4f6e7a41b6c5552d808df31a351d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 2 Aug 2020 18:52:05 +0200 Subject: [PATCH 02/22] requires PHP 7.2 --- .github/workflows/tests.yml | 4 ++-- .travis.yml | 1 - appveyor.yml | 2 +- composer.json | 2 +- readme.md | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e8275301..6730be9b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - php: ['7.1', '7.2', '7.3', '7.4', '8.0'] + php: ['7.2', '7.3', '7.4', '8.0'] # sapi: ['php', 'php-cgi'] fail-fast: false @@ -38,7 +38,7 @@ jobs: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 with: - php-version: 7.1 + php-version: 7.2 coverage: none extensions: fileinfo, intl diff --git a/.travis.yml b/.travis.yml index cb943ce6..a8a8869f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: php php: - - 7.1 - 7.2 - 7.3 - 7.4 diff --git a/appveyor.yml b/appveyor.yml index 0c9820f0..a672440d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,7 +14,7 @@ install: # Install PHP - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) - IF %PHP%==1 cd c:\php - - IF %PHP%==1 curl https://windows.php.net/downloads/releases/archives/php-7.1.0-Win32-VC14-x64.zip --output php.zip + - IF %PHP%==1 curl https://windows.php.net/downloads/releases/archives/php-7.2.28-Win32-VC15-x64.zip --output php.zip - IF %PHP%==1 7z x php.zip >nul - IF %PHP%==1 echo extension_dir=ext >> php.ini - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini diff --git a/composer.json b/composer.json index 6f681437..9ec06fb8 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": ">=7.1 <8.1", + "php": ">=7.2 <8.1", "nette/utils": "^3.1" }, "require-dev": { diff --git a/readme.md b/readme.md index 383eee0d..478c90a4 100644 --- a/readme.md +++ b/readme.md @@ -23,7 +23,7 @@ Installation: composer require nette/http ``` -It requires PHP version 7.1 and supports PHP up to 8.0. +It requires PHP version 7.2 and supports PHP up to 8.0. HTTP Request From de8299f57a4782229d865dc922f9430a01e05fa5 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 7 Jul 2020 00:09:27 +0200 Subject: [PATCH 03/22] Url: silently deprecated getBasePath(), getBaseUrl(), getRelativeUrl(), canonicalize() --- src/Http/Url.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Http/Url.php b/src/Http/Url.php index e282a486..64ee5fee 100644 --- a/src/Http/Url.php +++ b/src/Http/Url.php @@ -16,13 +16,13 @@ * Mutable representation of a URL. * *
- * scheme  user  password  host  port  basePath   relativeUrl
- *   |      |      |        |      |    |             |
- * /--\   /--\ /------\ /-------\ /--\/--\/----------------------------\
+ * scheme  user  password  host  port      path        query    fragment
+ *   |      |      |        |      |        |            |         |
+ * /--\   /--\ /------\ /-------\ /--\/------------\ /--------\ /------\
  * http://john:x0y17575@nette.org:8042/en/manual.php?name=param#fragment  <-- absoluteUrl
- *        \__________________________/\____________/^\________/^\______/
- *                     |                     |           |         |
- *                 authority               path        query    fragment
+ * \______\__________________________/
+ *     |               |
+ *  hostUrl        authority
  * 
* * @property string $scheme @@ -316,6 +316,7 @@ public function getHostUrl(): string } + /** @deprecated */ public function getBasePath(): string { $pos = strrpos($this->path, '/'); @@ -323,12 +324,14 @@ public function getBasePath(): string } + /** @deprecated */ public function getBaseUrl(): string { return $this->getHostUrl() . $this->getBasePath(); } + /** @deprecated */ public function getRelativeUrl(): string { return substr($this->getAbsoluteUrl(), strlen($this->getBaseUrl())); @@ -360,6 +363,7 @@ public function isEqual($url): bool /** * Transforms URL to canonical form. * @return static + * @deprecated */ public function canonicalize() { From 4908b840e467a69090874d978c3fb03dd25ccdaa Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 20 Oct 2020 18:23:59 +0200 Subject: [PATCH 04/22] FileUpload::getName() is silently deprecated --- src/Http/FileUpload.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Http/FileUpload.php b/src/Http/FileUpload.php index e0d149cb..490ad882 100644 --- a/src/Http/FileUpload.php +++ b/src/Http/FileUpload.php @@ -62,9 +62,7 @@ public function __construct(?array $value) /** - * Returns the original file name as submitted by the browser. Do not trust the value returned by this method. - * A client could send a malicious filename with the intention to corrupt or hack your application. - * Alias for getUntrustedName() + * @deprecated use getUntrustedName() */ public function getName(): string { From 39ba70e2f433121df9cc2251197d05abb2420959 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 7 Jul 2020 00:10:25 +0200 Subject: [PATCH 05/22] Session: deprecated getCookieParameters() triggers E_USER_DEPRECATED --- src/Http/Session.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Http/Session.php b/src/Http/Session.php index db98c6a6..bb9fc310 100644 --- a/src/Http/Session.php +++ b/src/Http/Session.php @@ -466,6 +466,7 @@ public function setCookieParameters( /** @deprecated */ public function getCookieParameters(): array { + trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED); return session_get_cookie_params(); } From 96d46c6ac9f63f0e8e49c1badaf2245922116e34 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 18 Nov 2019 21:29:37 +0100 Subject: [PATCH 06/22] HttpExtension: cookieSecure is by default 'auto' (BC break) --- src/Bridges/HttpDI/HttpExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index d4e0cd4a..b43982c4 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -40,7 +40,7 @@ public function getConfigSchema(): Nette\Schema\Schema 'csp' => Expect::arrayOf('array|scalar|null'), // Content-Security-Policy 'cspReportOnly' => Expect::arrayOf('array|scalar|null'), // Content-Security-Policy-Report-Only 'featurePolicy' => Expect::arrayOf('array|scalar|null'), // Feature-Policy - 'cookieSecure' => Expect::anyOf(null, true, false, 'auto'), // true|false|auto Whether the cookie is available only through HTTPS + 'cookieSecure' => Expect::anyOf(null, true, false, 'auto')->default('auto'), // true|false|auto Whether the cookie is available only through HTTPS ]); } From 5d3078d34630c8930780609e387163cb3a1e8a2c Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 2 Aug 2020 18:35:46 +0200 Subject: [PATCH 07/22] Request::getFile() accepts array of keys and returns FileUpload|null (BC break) WIP --- src/Http/Request.php | 10 +++++++--- tests/Http/Request.files.phpt | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Http/Request.php b/src/Http/Request.php index 802c1742..65bc31e0 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -142,11 +142,15 @@ public function getPost(string $key = null) /** * Returns uploaded file. - * @return FileUpload|array|null + * @param string|string[] $key + * @return ?FileUpload */ - public function getFile(string $key) + public function getFile($key) { - return $this->files[$key] ?? null; + $res = Nette\Utils\Arrays::get($this->files, $key, null); + return $res instanceof FileUpload + ? $res + : null; } diff --git a/tests/Http/Request.files.phpt b/tests/Http/Request.files.phpt index 5212508f..c9b1ee94 100644 --- a/tests/Http/Request.files.phpt +++ b/tests/Http/Request.files.phpt @@ -111,4 +111,4 @@ Assert::false(isset($request->files['file0'])); Assert::true(isset($request->files['file1'])); Assert::null($request->getFile('empty1')); -Assert::same([null], $request->getFile('empty2')); +Assert::null($request->getFile('empty2')); From b2a909336946a44b7d71093bf7350b9377016140 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 15 Oct 2020 20:28:31 +0200 Subject: [PATCH 08/22] RequestFactory: throws exception on invalid $_POST/$_COOKIE data --- src/Http/RequestFactory.php | 5 ++++- tests/Http/Request.invalidType.phpt | 34 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/Http/Request.invalidType.phpt diff --git a/src/Http/RequestFactory.php b/src/Http/RequestFactory.php index 76e057bc..71d8d161 100644 --- a/src/Http/RequestFactory.php +++ b/src/Http/RequestFactory.php @@ -163,8 +163,11 @@ private function getGetPostCookie(Url $url): array $list[$key][$k] = $v; $list[] = &$list[$key][$k]; - } else { + } elseif (is_string($v)) { $list[$key][$k] = (string) preg_replace('#[^' . self::CHARS . ']+#u', '', $v); + + } else { + throw new Nette\InvalidStateException(sprintf('Invalid value in $_POST/$_COOKIE in key %s, expected string, %s given.', "'$k'", gettype($v))); } } } diff --git a/tests/Http/Request.invalidType.phpt b/tests/Http/Request.invalidType.phpt new file mode 100644 index 00000000..0dd6d6e4 --- /dev/null +++ b/tests/Http/Request.invalidType.phpt @@ -0,0 +1,34 @@ + 1, + ]; + + Assert::exception(function () { + (new Http\RequestFactory)->fromGlobals(); + }, Nette\InvalidStateException::class, 'Invalid value in $_POST/$_COOKIE in key \'int\', expected string, integer given.'); +}); + + +test('invalid COOKIE', function () { + $_POST = []; + $_COOKIE = ['x' => [1]]; + + Assert::exception(function () { + (new Http\RequestFactory)->fromGlobals(); + }, Nette\InvalidStateException::class, 'Invalid value in $_POST/$_COOKIE in key \'0\', expected string, integer given.'); +}); From 0c0f9d24c8ba548efffa87937ee42ae258aedde3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bou=C4=8Dek?= Date: Mon, 16 Nov 2020 03:30:45 +0100 Subject: [PATCH 09/22] ScriptUrl: Fix class extendability (#187) (#188) --- src/Http/UrlScript.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Http/UrlScript.php b/src/Http/UrlScript.php index e43f17f8..fdc26fae 100644 --- a/src/Http/UrlScript.php +++ b/src/Http/UrlScript.php @@ -54,7 +54,8 @@ public function withPath(string $path, string $scriptPath = '') { $dolly = clone $this; $dolly->scriptPath = $scriptPath; - return call_user_func([$dolly, 'parent::withPath'], $path); + $parent = \Closure::fromCallable([UrlImmutable::class, 'withPath'])->bindTo($dolly); + return $parent($path); } From 9220b335ee0ad7734935936352f2aae9ad6bdfd1 Mon Sep 17 00:00:00 2001 From: nargotik <964518+nargotik@users.noreply.github.com> Date: Sun, 6 Dec 2020 23:05:00 +0000 Subject: [PATCH 10/22] Add files via upload --- ...ttpExtension.sameSiteProtectionCustom.phpt | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/Http.DI/HttpExtension.sameSiteProtectionCustom.phpt diff --git a/tests/Http.DI/HttpExtension.sameSiteProtectionCustom.phpt b/tests/Http.DI/HttpExtension.sameSiteProtectionCustom.phpt new file mode 100644 index 00000000..a92c932c --- /dev/null +++ b/tests/Http.DI/HttpExtension.sameSiteProtectionCustom.phpt @@ -0,0 +1,38 @@ +addExtension('http', new HttpExtension); +$loader = new DI\Config\Loader; +$config = $loader->load(Tester\FileMock::create(<<<'EOD' +http: + cookieNameStrict: test-samesite +EOD +, 'neon')); + +// protection is enabled by default +eval($compiler->addConfig($config)->compile()); + +$container = new Container; +$container->initialize(); + +$headers = headers_list(); +Assert::contains( + PHP_VERSION_ID >= 70300 + ? 'Set-Cookie: test-samesite=1; path=/; HttpOnly; SameSite=Strict' + : 'Set-Cookie: test-samesite=1; path=/; SameSite=Strict; HttpOnly', + $headers +); From 137d8f1dcce213fde3aff4491bba699f39db5ca5 Mon Sep 17 00:00:00 2001 From: nargotik <964518+nargotik@users.noreply.github.com> Date: Sun, 6 Dec 2020 23:05:32 +0000 Subject: [PATCH 11/22] Update Helpers.php --- src/Http/Helpers.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Http/Helpers.php b/src/Http/Helpers.php index 02332bbf..82a5ef7c 100644 --- a/src/Http/Helpers.php +++ b/src/Http/Helpers.php @@ -52,10 +52,10 @@ public static function ipMatch(string $ip, string $mask): bool } - public static function initCookie(IRequest $request, IResponse $response) + public static function initCookie(IRequest $request, IResponse $response, $cookieName = self::STRICT_COOKIE_NAME) { - if (!$request->getCookie(self::STRICT_COOKIE_NAME)) { - $response->setCookie(self::STRICT_COOKIE_NAME, '1', 0, '/', null, null, true, 'Strict'); + if (!$request->getCookie($cookieName)) { + $response->setCookie($cookieName, '1', 0, '/', null, null, true, 'Strict'); } } } From 68943373e3c45704b322590c2ce96f3bb31380b6 Mon Sep 17 00:00:00 2001 From: nargotik <964518+nargotik@users.noreply.github.com> Date: Sun, 6 Dec 2020 23:06:26 +0000 Subject: [PATCH 12/22] Add cookieNameStrict Option --- src/Bridges/HttpDI/HttpExtension.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index b43982c4..707da4af 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -41,6 +41,7 @@ public function getConfigSchema(): Nette\Schema\Schema 'cspReportOnly' => Expect::arrayOf('array|scalar|null'), // Content-Security-Policy-Report-Only 'featurePolicy' => Expect::arrayOf('array|scalar|null'), // Feature-Policy 'cookieSecure' => Expect::anyOf(null, true, false, 'auto')->default('auto'), // true|false|auto Whether the cookie is available only through HTTPS + 'cookieNameStrict' => Expect::anyOf(Expect::string(), Expect::bool(), null)->default('nette-samesite'), ]); } @@ -121,8 +122,8 @@ private function sendHeaders() } $this->initialization->addBody( - 'Nette\Http\Helpers::initCookie($this->getService(?), $response);', - [$this->prefix('request')] + 'Nette\Http\Helpers::initCookie($this->getService(?), $response, ?);', + [$this->prefix('request') , $config->cookieNameStrict] ); } From 9f931c84eca079414af6b05d0f0ba6be2cfad762 Mon Sep 17 00:00:00 2001 From: nargotik <964518+nargotik@users.noreply.github.com> Date: Sun, 6 Dec 2020 23:07:03 +0000 Subject: [PATCH 13/22] Update HttpExtension.php --- src/Bridges/HttpDI/HttpExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index 707da4af..fd83159d 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -41,7 +41,7 @@ public function getConfigSchema(): Nette\Schema\Schema 'cspReportOnly' => Expect::arrayOf('array|scalar|null'), // Content-Security-Policy-Report-Only 'featurePolicy' => Expect::arrayOf('array|scalar|null'), // Feature-Policy 'cookieSecure' => Expect::anyOf(null, true, false, 'auto')->default('auto'), // true|false|auto Whether the cookie is available only through HTTPS - 'cookieNameStrict' => Expect::anyOf(Expect::string(), Expect::bool(), null)->default('nette-samesite'), + 'cookieNameStrict' => Expect::anyOf(Expect::string(), Expect::bool(), null)->default('nette-samesite'), ]); } From 9d4bcaf10574c2be9a09a485484db36117d2a7a2 Mon Sep 17 00:00:00 2001 From: nargotik <964518+nargotik@users.noreply.github.com> Date: Sun, 6 Dec 2020 23:10:18 +0000 Subject: [PATCH 14/22] Update HttpExtension.php --- src/Bridges/HttpDI/HttpExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index fd83159d..3409fd15 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -41,7 +41,7 @@ public function getConfigSchema(): Nette\Schema\Schema 'cspReportOnly' => Expect::arrayOf('array|scalar|null'), // Content-Security-Policy-Report-Only 'featurePolicy' => Expect::arrayOf('array|scalar|null'), // Feature-Policy 'cookieSecure' => Expect::anyOf(null, true, false, 'auto')->default('auto'), // true|false|auto Whether the cookie is available only through HTTPS - 'cookieNameStrict' => Expect::anyOf(Expect::string(), Expect::bool(), null)->default('nette-samesite'), + 'cookieNameStrict' => Expect::anyOf(Expect::string(), Expect::bool(), null)->default('nette-samesite'), ]); } @@ -123,7 +123,7 @@ private function sendHeaders() $this->initialization->addBody( 'Nette\Http\Helpers::initCookie($this->getService(?), $response, ?);', - [$this->prefix('request') , $config->cookieNameStrict] + [$this->prefix('request'), $config->cookieNameStrict] ); } From 89f80052940e98b3fce9bbd8ef23435938ae6005 Mon Sep 17 00:00:00 2001 From: nargotik <964518+nargotik@users.noreply.github.com> Date: Sun, 6 Dec 2020 23:54:06 +0000 Subject: [PATCH 15/22] Update HttpExtension.php --- src/Bridges/HttpDI/HttpExtension.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index 3409fd15..32713832 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -55,6 +55,10 @@ public function loadConfiguration() ->setFactory(Nette\Http\RequestFactory::class) ->addSetup('setProxy', [$config->proxy]); + $builder->addDefinition($this->prefix('request')) + ->setFactory(Nette\Http\Request::class) + ->addSetup('set_cookieNameStrict', [$config->cookieNameStrict]); + $builder->addDefinition($this->prefix('request')) ->setFactory('@Nette\Http\RequestFactory::fromGlobals'); From 8e560d43e12e606f765002f70f34cbd2130d809b Mon Sep 17 00:00:00 2001 From: nargotik <964518+nargotik@users.noreply.github.com> Date: Sun, 6 Dec 2020 23:54:06 +0000 Subject: [PATCH 16/22] Revert "Update HttpExtension.php" This reverts commit 89f80052940e98b3fce9bbd8ef23435938ae6005. --- src/Bridges/HttpDI/HttpExtension.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index 32713832..3409fd15 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -55,10 +55,6 @@ public function loadConfiguration() ->setFactory(Nette\Http\RequestFactory::class) ->addSetup('setProxy', [$config->proxy]); - $builder->addDefinition($this->prefix('request')) - ->setFactory(Nette\Http\Request::class) - ->addSetup('set_cookieNameStrict', [$config->cookieNameStrict]); - $builder->addDefinition($this->prefix('request')) ->setFactory('@Nette\Http\RequestFactory::fromGlobals'); From f2873f7599e645bd777692d6bf2c625fe57931a8 Mon Sep 17 00:00:00 2001 From: nargotik Date: Mon, 7 Dec 2020 00:05:30 +0000 Subject: [PATCH 17/22] isSameSite fix for new cookie name --- src/Bridges/HttpDI/HttpExtension.php | 4 ++++ src/Http/Request.php | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index 3409fd15..ee37588a 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -58,6 +58,10 @@ public function loadConfiguration() $builder->addDefinition($this->prefix('request')) ->setFactory('@Nette\Http\RequestFactory::fromGlobals'); + $builder->addDefinition($this->prefix('request')) + ->setFactory(Nette\Http\Request::class) + ->addSetup('set_cookieNameStrict', [$config->cookieNameStrict]); + $response = $builder->addDefinition($this->prefix('response')) ->setFactory(Nette\Http\Response::class); diff --git a/src/Http/Request.php b/src/Http/Request.php index 65bc31e0..859a819d 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -60,6 +60,9 @@ class Request implements IRequest /** @var callable|null */ private $rawBodyCallback; + /** @var string */ + private $cookieNameStrict; + public function __construct( UrlScript $url, @@ -81,8 +84,16 @@ public function __construct( $this->remoteAddress = $remoteAddress; $this->remoteHost = $remoteHost; $this->rawBodyCallback = $rawBodyCallback; + $this->cookieNameStrict = Helpers::STRICT_COOKIE_NAME; } + /** + * Setter for cookieNameStrict + * @param string $name + */ + public function set_cookieNameStrict(string $name) { + $this->cookieNameStrict = $name; + } /** * Returns a clone with a different URL. @@ -253,7 +264,7 @@ public function isSecured(): bool */ public function isSameSite(): bool { - return isset($this->cookies[Helpers::STRICT_COOKIE_NAME]); + return isset($this->cookies[$this->cookieNameStrict]); } From 9143c2cd9ab8e1634244815838d104ec2269a741 Mon Sep 17 00:00:00 2001 From: nargotik Date: Mon, 7 Dec 2020 00:12:01 +0000 Subject: [PATCH 18/22] isSameSite fix after new configuration value --- src/Bridges/HttpDI/HttpExtension.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index ee37588a..030b6397 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -56,11 +56,8 @@ public function loadConfiguration() ->addSetup('setProxy', [$config->proxy]); $builder->addDefinition($this->prefix('request')) - ->setFactory('@Nette\Http\RequestFactory::fromGlobals'); - - $builder->addDefinition($this->prefix('request')) - ->setFactory(Nette\Http\Request::class) - ->addSetup('set_cookieNameStrict', [$config->cookieNameStrict]); + ->setFactory('@Nette\Http\RequestFactory::fromGlobals') + ->addSetup('set_cookieNameStrict', [$config->cookieNameStrict]);; $response = $builder->addDefinition($this->prefix('response')) ->setFactory(Nette\Http\Response::class); From 1390bb619054158264a99ee5e705a080fd939d1e Mon Sep 17 00:00:00 2001 From: nargotik Date: Mon, 7 Dec 2020 00:18:25 +0000 Subject: [PATCH 19/22] fix Setter Name setCookieNameStrict --- src/Bridges/HttpDI/HttpExtension.php | 2 +- src/Http/Request.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index 030b6397..1ac19ca9 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -57,7 +57,7 @@ public function loadConfiguration() $builder->addDefinition($this->prefix('request')) ->setFactory('@Nette\Http\RequestFactory::fromGlobals') - ->addSetup('set_cookieNameStrict', [$config->cookieNameStrict]);; + ->addSetup('setCookieNameStrict', [$config->cookieNameStrict]);; $response = $builder->addDefinition($this->prefix('response')) ->setFactory(Nette\Http\Response::class); diff --git a/src/Http/Request.php b/src/Http/Request.php index 859a819d..7b1b5c6b 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -91,7 +91,7 @@ public function __construct( * Setter for cookieNameStrict * @param string $name */ - public function set_cookieNameStrict(string $name) { + public function setCookieNameStrict(string $name) { $this->cookieNameStrict = $name; } From 08f9ee1b7f51e6858e53dce59b9b1398360d0761 Mon Sep 17 00:00:00 2001 From: nargotik Date: Mon, 7 Dec 2020 00:23:54 +0000 Subject: [PATCH 20/22] Ident fix --- src/Http/Request.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Http/Request.php b/src/Http/Request.php index 7b1b5c6b..8605e1d2 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -87,11 +87,12 @@ public function __construct( $this->cookieNameStrict = Helpers::STRICT_COOKIE_NAME; } - /** + /** * Setter for cookieNameStrict * @param string $name */ - public function setCookieNameStrict(string $name) { + public function setCookieNameStrict(string $name) + { $this->cookieNameStrict = $name; } From 344fe985fce85025072f71971412145032b30501 Mon Sep 17 00:00:00 2001 From: nargotik Date: Mon, 7 Dec 2020 00:26:07 +0000 Subject: [PATCH 21/22] double ; remove --- src/Bridges/HttpDI/HttpExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index 1ac19ca9..c5dbc163 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -57,7 +57,7 @@ public function loadConfiguration() $builder->addDefinition($this->prefix('request')) ->setFactory('@Nette\Http\RequestFactory::fromGlobals') - ->addSetup('setCookieNameStrict', [$config->cookieNameStrict]);; + ->addSetup('setCookieNameStrict', [$config->cookieNameStrict]); $response = $builder->addDefinition($this->prefix('response')) ->setFactory(Nette\Http\Response::class); From 994f954ec8f41ba306938f878c6d3db0ed44418e Mon Sep 17 00:00:00 2001 From: nargotik Date: Mon, 7 Dec 2020 00:29:28 +0000 Subject: [PATCH 22/22] \n fix --- src/Http/Request.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Http/Request.php b/src/Http/Request.php index 8605e1d2..b7a2519d 100644 --- a/src/Http/Request.php +++ b/src/Http/Request.php @@ -87,6 +87,7 @@ public function __construct( $this->cookieNameStrict = Helpers::STRICT_COOKIE_NAME; } + /** * Setter for cookieNameStrict * @param string $name @@ -96,6 +97,7 @@ public function setCookieNameStrict(string $name) $this->cookieNameStrict = $name; } + /** * Returns a clone with a different URL. * @return static