#109335FormProtection prevents form validation after cleaning session token.
Description
While using the Form Protection system, it becomes impossible to validate a form if the `clean()` function is called.
Class : typo3/cms-core/Classes/FormProtection/AbstractFormProtection.php
https://github.com/TYPO3/typo3/blob/13.4/typo3/sysext/core/Classes/FormProtection/AbstractFormProtection.php#L51
This function “clean” assigns the value ‘’ (empty string).
public function clean()
{
$this->sessionToken = ''; <---- here
$this->persistSessionToken();
}
However, generating a new session token becomes impossible because of the code in the `getSessionToken` function, which checks for the presence of a session token using the `??` test.
protected function getSessionToken()
{
$this->sessionToken = $this->sessionToken ?? $this->retrieveSessionToken();
return $this->sessionToken;
}
If the session token is ‘’ (empty string), the `??` test is valid and does not retrieve a new session token.
Possible solutions:
- set null in clean function :
$this->sessionToken = null;
- use ifempty test
if (empty($this->sessionToken)) {
$this->sessionToken = $this->retrieveSessionToken();
}Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[BUGFIX] FormProtection prevents form validation after cleaning session token. Resolves: #109335 Releases: main