diff --git a/middleware/VerifyCsrfTokenMiddleware.php b/middleware/VerifyCsrfTokenMiddleware.php index 088e160..94caf4a 100644 --- a/middleware/VerifyCsrfTokenMiddleware.php +++ b/middleware/VerifyCsrfTokenMiddleware.php @@ -13,6 +13,7 @@ use Illuminate\Routing\Redirector; use October\Rain\Cookie\Middleware\EncryptCookies; use RuntimeException; +use Throwable; /** * Class VerifyCsrfTokenMiddleware @@ -124,6 +125,10 @@ private function getTokenFromRequest(Request $request): string $token = $this->encrypter->decrypt($header, EncryptCookies::serialized('XSRF-TOKEN')); } - return (string) $token; + try { + return (string) $token; + } catch (Throwable $e) { + return ''; + } } } diff --git a/updates/version.yaml b/updates/version.yaml index a3aa967..77c226e 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -1,2 +1,3 @@ 1.0.0: "First version of Vdlp.Csrf -- See: https://github.com/vdlp/oc-csrf-plugin/releases/tag/1.0.0" 1.1.0: "Added configuration to exclude paths from CSRF validation -- See: https://github.com/vdlp/oc-csrf-plugin/releases/tag/1.1.0" +1.1.1: "Prevent error on CSRF token conversion -- See: https://github.com/vdlp/oc-csrf-plugin/releases/tag/1.1.1"