diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php index 6c905a00c047629641fe6966420dcb35f0bb1701..f5746868cde52973c0e439b55874f4836900723e 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php @@ -71,11 +71,6 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH */ protected $formActionUriArguments; - /** - * @var bool - */ - private $securedReferrerFieldRendered = false; - /** * @param \TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService */ @@ -176,6 +171,7 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH $this->removeFormObjectNameFromViewHelperVariableContainer(); $this->removeFormFieldNamesFromViewHelperVariableContainer(); $this->removeCheckboxFieldNamesFromViewHelperVariableContainer(); + $this->removeSecuredHiddenFieldsRenderedFromViewHelperVariableContainer(); return $this->tag->render(); } @@ -269,7 +265,7 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH */ protected function renderHiddenSecuredReferrerField() { - if ($this->securedReferrerFieldRendered) { + if ($this->hasSecuredHiddenFieldsRendered()) { return ''; } $request = $this->renderingContext->getControllerContext()->getRequest(); @@ -286,7 +282,7 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH $actionRequest['@vendor'] = $vendorName; } $result = '<input type="hidden" name="' . $this->prefixFieldName('__referrer[@request]') . '" value="' . htmlspecialchars($this->hashService->appendHmac(serialize($actionRequest))) . '" />' . LF; - $this->securedReferrerFieldRendered = true; + $this->addSecuredHiddenFieldsRenderedToViewHelperVariableContainer(); return $result; } @@ -399,6 +395,32 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH $this->viewHelperVariableContainer->remove(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'formFieldNames'); } + /** + * Adds flag to indicate the secured hidden fields have been rendered to the ViewHelperVariableContainer + */ + protected function addSecuredHiddenFieldsRenderedToViewHelperVariableContainer() + { + $this->viewHelperVariableContainer->add(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'securedHiddenFieldsRendered', true); + } + + /** + * Checks whether the secured hidden fields have been rendered + * + * @return bool + */ + protected function hasSecuredHiddenFieldsRendered() + { + return $this->viewHelperVariableContainer->exists(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'securedHiddenFieldsRendered'); + } + + /** + * Removes flag to indicate the secured hidden fields have been rendered from the ViewHelperVariableContainer + */ + protected function removeSecuredHiddenFieldsRenderedFromViewHelperVariableContainer() + { + $this->viewHelperVariableContainer->remove(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, 'securedHiddenFieldsRendered'); + } + /** * Render the request hash field *