Skip to content

Commit

Permalink
[WIP][BUGFIX] Prevent exception, when invalid mail uid is given
Browse files Browse the repository at this point in the history
Related: #969
  • Loading branch information
mschwemer committed Sep 18, 2024
1 parent 896cdab commit 058d204
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Classes/Controller/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
use Throwable;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
use TYPO3\CMS\Core\Http\PropagateResponseException;
use TYPO3\CMS\Core\Http\RedirectResponse;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation as ExtbaseAnnotation;
Expand Down Expand Up @@ -220,6 +222,7 @@ public function checkCreateAction(Mail $mail): ResponseInterface
* @throws ExtensionConfigurationPathDoesNotExistException
* @throws InvalidQueryException
* @throws NoSuchArgumentException
* @throws PropagateResponseException
*/
public function initializeCreateAction(): void
{
Expand All @@ -234,6 +237,11 @@ public function initializeCreateAction(): void
throw new PropagateResponseException($response);
}

$response = $this->forwardIfMailUidDoesNotExist();
if ($response !== null) {
throw new PropagateResponseException($response, 1726683851);
}

$this->reformatParamsForAction();
$this->debugVariables();
}
Expand Down Expand Up @@ -594,6 +602,21 @@ protected function forwardIfMailParamEmpty(): ?ForwardResponse
return null;
}

/**
* @return RedirectResponse|null
* @throws PropagateResponseException
*/
private function forwardIfMailUidDoesNotExist(): ?RedirectResponse
{
$arguments = $this->request->getArguments();
$mail = $this->mailRepository->findByUid($arguments['mail']);
if ($mail === null) {
$returnUrl = $this->request->getUri()->getPath();
return new RedirectResponse($returnUrl, 200);
}
return null;
}

/**
* Forward to formAction if wrong form in plugin variables given
* used in optinConfirmAction()
Expand Down

0 comments on commit 058d204

Please sign in to comment.