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 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/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/readme.md b/readme.md index ba652fff5..e3a65eaab 100644 --- a/readme.md +++ b/readme.md @@ -1,12 +1,6 @@ Nette Application MVC ===================== -[](https://packagist.org/packages/nette/application) -[](https://travis-ci.org/nette/application) -[](https://coveralls.io/github/nette/application?branch=master) -[](https://github.com/nette/application/releases) -[](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). 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)) { 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); 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 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' => ''])); }); 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 @@ +