Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make allowed_classes configurable when unserializing formState #144

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion Classes/Core/Runtime/FormRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
*/
protected $formState;

/**
* @Flow\InjectConfiguration(path="formState.allowedClasses")
* @var array
* @internal
*/
protected $allowedClassesInFormState;

/**
* The current page is the page which will be displayed to the user
* during rendering.
Expand Down Expand Up @@ -181,7 +188,7 @@ protected function initializeFormStateFromRequest()
$this->formState = new FormState();
} else {
$serializedFormState = $this->hashService->validateAndStripHmac($serializedFormStateWithHmac);
$this->formState = unserialize(base64_decode($serializedFormState), ['allowed_classes' => [FormState::class, \DateTime::class, \DateTimeImmutable::class]]);
$this->formState = unserialize(base64_decode($serializedFormState), ['allowed_classes' => array_filter($this->allowedClassesInFormState)]);
}
}

Expand Down
5 changes: 5 additions & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Neos:
savePath: '%FLOW_PATH_DATA%Forms/'
supertypeResolver:
hiddenProperties: { }
formState:
allowedClasses:
FormState: Neos\Form\Core\Runtime\FormState
DateTime: DateTime
DateTimeImmutable: DateTimeImmutable
presets:
default:
title: Default
Expand Down