Validate user timezone given from login data before saving it

Follow-up to #36000

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2023-01-04 17:52:02 +01:00
parent e235c6438c
commit 6b7da88b0b
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -43,7 +43,7 @@ class SetUserTimezoneCommand extends ALoginCommand {
}
public function process(LoginData $loginData): LoginResult {
if ($loginData->getTimeZoneOffset() !== '') {
if ($loginData->getTimeZoneOffset() !== '' && $this->isValidTimezone($loginData->getTimeZone())) {
$this->config->setUserValue(
$loginData->getUser()->getUID(),
'core',
@ -58,4 +58,8 @@ class SetUserTimezoneCommand extends ALoginCommand {
return $this->processNextOrFinishSuccessfully($loginData);
}
private function isValidTimezone(?string $value): bool {
return $value && in_array($value, \DateTimeZone::listIdentifiers());
}
}