Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Classes/Controller/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use In2code\Powermail\Utility\ObjectUtility;
use In2code\Powermail\Utility\SessionUtility;
use In2code\Powermail\Utility\TemplateUtility;
use TYPO3\CMS\Core\Error\Http\BadRequestException;
use function in_array;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -609,6 +610,17 @@ public function processRequest(RequestInterface $request): ResponseInterface
return parent::processRequest($request);
} catch (PropagateResponseException $e) {
return $e->getResponse();
} catch (BadRequestException $e) {
if (in_array($e->getCode(), [1581862822, 1699604555, 1691267306])) {
// If the trustedProperties HMAC can not be validated, we redirect to an empty form because the
// request cannot be salvaged and would lead to an infinite loop.
$logger = ObjectUtility::getLogger(__CLASS__);
$logger->warning('Redirecting to empty form because HMAC validation failed.', [$e->getMessage()]);
return $this->redirect('form');
}
$logger = ObjectUtility::getLogger(__CLASS__);
$logger->critical('An error occurred: ', [$e->getMessage()]);
return (new ForwardResponse('form'))->withoutArguments();
} catch (\Exception $e) {
$logger = ObjectUtility::getLogger(__CLASS__);
$logger->critical('An error occurred: ', [$e->getMessage()]);
Expand Down
Loading