From d2c71f44f0b0caefdada740e30d1e4b72efe9976 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 25 Jan 2021 00:23:46 +0100 Subject: [PATCH 1/7] updated workflows --- .github/workflows/tests.yml | 6 ++++-- tests/.coveralls.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aa8766a20..73516285b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,6 +53,8 @@ jobs: coverage: none - run: composer install --no-progress --prefer-dist - - run: wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar - run: vendor/bin/tester -p phpdbg tests -s -C --coverage ./coverage.xml --coverage-src ./src - - run: php coveralls.phar --verbose --config tests/.coveralls.yml + - run: wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar + - env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: php php-coveralls.phar --verbose --config tests/.coveralls.yml diff --git a/tests/.coveralls.yml b/tests/.coveralls.yml index 82764a3f5..845038250 100644 --- a/tests/.coveralls.yml +++ b/tests/.coveralls.yml @@ -1,4 +1,4 @@ # for php-coveralls -service_name: travis-ci +service_name: github-actions coverage_clover: coverage.xml json_path: coverage.json From 72d5945c67603553d4f4e3c39489a3937790a604 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 25 Jan 2021 14:17:32 +0100 Subject: [PATCH 2/7] Form::disableSameSiteProtection() replaced with allowCrossOrigin() --- src/Application/UI/Form.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Application/UI/Form.php b/src/Application/UI/Form.php index 2e7ceca03..0d986c7fc 100644 --- a/src/Application/UI/Form.php +++ b/src/Application/UI/Form.php @@ -21,7 +21,7 @@ class Form extends Nette\Forms\Form implements ISignalReceiver public $onAnchor; /** @var bool */ - private $sameSiteProtection = true; + protected $crossOrigin = false; /** @@ -103,9 +103,16 @@ public function isAnchored(): bool /** * Disables CSRF protection using a SameSite cookie. */ + public function allowCrossOrigin(): void + { + $this->crossOrigin = true; + } + + + /** @deprecated use allowCrossOrigin() */ public function disableSameSiteProtection(): void { - $this->sameSiteProtection = false; + $this->crossOrigin = true; } @@ -153,7 +160,7 @@ public function signalReceived(string $signal): void $class = static::class; throw new BadSignalException("Missing handler for signal '$signal' in $class."); - } elseif ($this->sameSiteProtection && !$this->getPresenter()->getHttpRequest()->isSameSite()) { + } elseif (!$this->crossOrigin && !$this->getPresenter()->getHttpRequest()->isSameSite()) { $this->getPresenter()->detectedCsrf(); } elseif (!$this->getPresenter()->getRequest()->hasFlag(Nette\Application\Request::RESTORED)) { From 3d9ea92ab36f5e1475b8dd93a27da03d5fc3b8c7 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 25 Jan 2021 21:00:12 +0100 Subject: [PATCH 3/7] readme: removed badges --- readme.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/readme.md b/readme.md index ba652fff5..e3a65eaab 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,6 @@ Nette Application MVC ===================== -[![Downloads this Month](https://img.shields.io/packagist/dm/nette/application.svg)](https://packagist.org/packages/nette/application) -[![Build Status](https://travis-ci.org/nette/application.svg?branch=master)](https://travis-ci.org/nette/application) -[![Coverage Status](https://coveralls.io/repos/github/nette/application/badge.svg?branch=master)](https://coveralls.io/github/nette/application?branch=master) -[![Latest Stable Version](https://poser.pugx.org/nette/application/v/stable)](https://github.com/nette/application/releases) -[![License](https://img.shields.io/badge/license-New%20BSD-blue.svg)](https://github.com/nette/application/blob/master/license.md) - Model-View-Controller is a software architecture that was created to satisfy the need to separate utility code (controller) from application logic code (model) and from code for displaying data (view) in applications with graphical user interface. With this approach we make the application better understandable, simplify future development and enable testing each unit of the application separately. Please, [see documentation](https://doc.nette.org/application). From 7022802b056ebaf8e860c349e704de0f4de54201 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 5 Feb 2021 23:17:52 +0100 Subject: [PATCH 4/7] tests: cs --- tests/UI/Presenter.formatLayoutTemplateFiles.phpt | 14 +++++++------- tests/UI/Presenter.formatTemplateFiles.phpt | 12 ++++++------ tests/UI/one/APresenter.php | 7 +++++++ tests/UI/one/Presenter1.php | 7 ------- tests/UI/two/{Presenter2.php => BPresenter.php} | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 tests/UI/one/APresenter.php delete mode 100644 tests/UI/one/Presenter1.php rename tests/UI/two/{Presenter2.php => BPresenter.php} (50%) diff --git a/tests/UI/Presenter.formatLayoutTemplateFiles.phpt b/tests/UI/Presenter.formatLayoutTemplateFiles.phpt index fcde28dc4..645bb7135 100644 --- a/tests/UI/Presenter.formatLayoutTemplateFiles.phpt +++ b/tests/UI/Presenter.formatLayoutTemplateFiles.phpt @@ -10,12 +10,12 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -require __DIR__ . '/one/Presenter1.php'; -require __DIR__ . '/two/Presenter2.php'; +require __DIR__ . '/one/APresenter.php'; +require __DIR__ . '/two/BPresenter.php'; test('with subdir templates', function () { - $presenter = new Presenter1; + $presenter = new APresenter; $presenter->setParent(null, 'One'); $presenter->setLayout('my'); @@ -28,7 +28,7 @@ test('with subdir templates', function () { test('without subdir templates', function () { - $presenter = new Presenter2; + $presenter = new BPresenter; $presenter->setParent(null, 'Two'); Assert::same([ @@ -40,7 +40,7 @@ test('without subdir templates', function () { test('with module & subdir templates', function () { - $presenter = new Presenter1; + $presenter = new APresenter; $presenter->setParent(null, 'Module:SubModule:One'); Assert::same([ @@ -54,7 +54,7 @@ test('with module & subdir templates', function () { test('with module & without subdir templates', function () { - $presenter = new Presenter2; + $presenter = new BPresenter; $presenter->setParent(null, 'Module:SubModule:Two'); Assert::same([ @@ -68,7 +68,7 @@ test('with module & without subdir templates', function () { test('direct file', function () { - $presenter = new Presenter2; + $presenter = new BPresenter; $presenter->setLayout(__DIR__ . '/file.latte'); Assert::same([ diff --git a/tests/UI/Presenter.formatTemplateFiles.phpt b/tests/UI/Presenter.formatTemplateFiles.phpt index 4f55d48c4..427d4775f 100644 --- a/tests/UI/Presenter.formatTemplateFiles.phpt +++ b/tests/UI/Presenter.formatTemplateFiles.phpt @@ -10,12 +10,12 @@ use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -require __DIR__ . '/one/Presenter1.php'; -require __DIR__ . '/two/Presenter2.php'; +require __DIR__ . '/one/APresenter.php'; +require __DIR__ . '/two/BPresenter.php'; test('with subdir templates', function () { - $presenter = new Presenter1; + $presenter = new APresenter; $presenter->setParent(null, 'One'); $presenter->setView('view'); @@ -27,7 +27,7 @@ test('with subdir templates', function () { test('without subdir templates', function () { - $presenter = new Presenter2; + $presenter = new BPresenter; $presenter->setParent(null, 'Two'); $presenter->setView('view'); @@ -39,7 +39,7 @@ test('without subdir templates', function () { test('with module & subdir templates', function () { - $presenter = new Presenter1; + $presenter = new APresenter; $presenter->setParent(null, 'Module:One'); $presenter->setView('view'); @@ -51,7 +51,7 @@ test('with module & subdir templates', function () { test('with module & without subdir templates', function () { - $presenter = new Presenter2; + $presenter = new BPresenter; $presenter->setParent(null, 'Module:Two'); $presenter->setView('view'); diff --git a/tests/UI/one/APresenter.php b/tests/UI/one/APresenter.php new file mode 100644 index 000000000..fb76d41b8 --- /dev/null +++ b/tests/UI/one/APresenter.php @@ -0,0 +1,7 @@ + Date: Mon, 8 Feb 2021 04:32:36 +0100 Subject: [PATCH 5/7] composer: accepts routing 3.1 --- composer.json | 2 +- tests/Routers/Route.optional.autooptional3.phpt | 4 ++-- tests/Routers/Route.scalarParams.phpt | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 696841b3a..be5868205 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "php": ">=7.1", "nette/component-model": "^3.0", "nette/http": "^3.0.2", - "nette/routing": "~3.0.0", + "nette/routing": "^3.0", "nette/utils": "^3.1" }, "suggest": { diff --git a/tests/Routers/Route.optional.autooptional3.phpt b/tests/Routers/Route.optional.autooptional3.phpt index e75e101a0..020192b63 100644 --- a/tests/Routers/Route.optional.autooptional3.phpt +++ b/tests/Routers/Route.optional.autooptional3.phpt @@ -37,10 +37,10 @@ Assert::null(testRouteOut($route, ['presenter' => 'Homepage', 'default' => 'abc' Assert::same( 'http://example.com/homepage/123/xyz', - testRouteOut($route, ['presenter' => 'Homepage', 'required' => 'xyz']) + testRouteOut($route, ['presenter' => 'Homepage', 'action' => 'default', 'required' => 'xyz']) ); Assert::same( 'http://example.com/homepage/abc/xyz', - testRouteOut($route, ['presenter' => 'Homepage', 'required' => 'xyz', 'default' => 'abc']) + testRouteOut($route, ['presenter' => 'Homepage', 'action' => 'default', 'required' => 'xyz', 'default' => 'abc']) ); diff --git a/tests/Routers/Route.scalarParams.phpt b/tests/Routers/Route.scalarParams.phpt index 2d1224792..7791a9020 100644 --- a/tests/Routers/Route.scalarParams.phpt +++ b/tests/Routers/Route.scalarParams.phpt @@ -209,6 +209,4 @@ test('', function () { 'http://example.com/homepage/', testRouteOut($route, ['presenter' => 'Homepage', 'param' => null]) ); - - Assert::null(testRouteOut($route, ['presenter' => 'Homepage', 'param' => ''])); }); From 44e8c2d9ecec10241be663cae13b7be3c26e6a33 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 9 May 2021 14:43:31 +0200 Subject: [PATCH 6/7] typo --- src/Application/UI/Presenter.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 56f0616aa..c36aa3956 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -251,8 +251,6 @@ public function run(Application\Request $request): Application\IResponse if ($this->isAjax()) { try { - $hasPayload = (array) $this->payload; - unset($hasPayload['state']); if ($this->response instanceof Responses\TextResponse && $this->isControlInvalid()) { $this->snippetMode = true; $this->response->send($this->httpRequest, $this->httpResponse); From 00ea7a7f0ec32b52ba0bd0e0d4e6934040ab4f0e Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 2 Jun 2022 13:37:44 +0200 Subject: [PATCH 7/7] fixed GitHub actions --- .github/workflows/coding-style.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coding-style.yml b/.github/workflows/coding-style.yml index 86f9bdcc4..6965296cd 100644 --- a/.github/workflows/coding-style.yml +++ b/.github/workflows/coding-style.yml @@ -27,5 +27,5 @@ jobs: php-version: 8.0 coverage: none - - run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress --ignore-platform-reqs + - run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress - run: php temp/coding-standard/ecs check