Skip to content

SameOrigin validation fails with custom Nette\Http\IRequest implementation #371

Description

@janfejtek

Version: 3.3.0

Bug Description

Form validation for received signal $presenter->getHttpRequest()->isFrom(Nette\Http\FetchSite::SameOrigin) fails if custom Request class is used. Calling isFrom is not possible on IRequest interface as it does not exist

} elseif (!$this->crossOrigin && !$presenter->getHttpRequest()->isFrom(Nette\Http\FetchSite::SameOrigin)) {
$presenter->detectedCsrf();

Steps To Reproduce

For example PHPStan or just add custom class implementing https://github.com/nette/http/blob/master/src/Http/IRequest.php

Expected Behavior

Do not throw exception when for example Contributte\Codeception\Http\Request is used which does not have isFrom implemented

Possible Solution

add check with instanceof

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions