diff --git a/CHANGELOG.md b/CHANGELOG.md index e884808c7c..1d938c379a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ HumHub Changelog - Fix #5657: Fix links of user counters in container headers - Fix #5676: Use 404 page for deleted content request - Fix #5679: Fix message on decline multiple users - +- Fix #5689: Check value on colorpicker 1.11.1 (April 22, 2022) ----------------------- diff --git a/protected/humhub/modules/ui/form/widgets/ColorPicker.php b/protected/humhub/modules/ui/form/widgets/ColorPicker.php index 9baf70c123..a7f1295777 100644 --- a/protected/humhub/modules/ui/form/widgets/ColorPicker.php +++ b/protected/humhub/modules/ui/form/widgets/ColorPicker.php @@ -49,7 +49,8 @@ public function init() $this->attribute = $this->field; } - if($this->hasModel() && !$this->getValue() && $this->randomDefault) { + if (($this->hasModel() && !$this->getValue() && $this->randomDefault) || + !$this->isCorrectColorValue()) { $attr = $this->attribute; $this->model->$attr = RandomColor::one(['luminosity' => 'dark']); } @@ -68,4 +69,9 @@ public function run() ]); } + private function isCorrectColorValue(): bool + { + return preg_match('/^#[a-f0-9]{3,6}$/i', $this->model->{$this->attribute}); + } + }