Trim Base URL on save (#6737)

* Trim Base URL on save

* Use url and trim validators for general setting "Base URL"

---------

Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
Yuriy Bakhtin 2023-12-14 16:00:24 +01:00 committed by GitHub
parent 9e2411392c
commit c5a8d91918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -3,6 +3,7 @@ HumHub Changelog
1.15.2 (Unreleased)
-------------------------
- Enh #6734: Trim Base URL on save
- Fix #6708: Fix displaying of alert when RichText is changed on refresh a page
1.15.1 (December 13, 2023)

View File

@ -57,11 +57,8 @@ class BasicSettingsForm extends \yii\base\Model
['defaultLanguage', 'in', 'range' => array_keys(Yii::$app->i18n->getAllowedLanguages())],
[['defaultTimeZone', 'timeZone'], 'in', 'range' => \DateTimeZone::listIdentifiers()],
[['tour', 'dashboardShowProfilePostForm', 'enableFriendshipModule', 'maintenanceMode'], 'in', 'range' => [0, 1]],
[['baseUrl'], function ($attribute, $params, $validator) {
if (substr($this->$attribute, 0, 7) !== 'http://' && substr($this->$attribute, 0, 8) !== 'https://') {
$this->addError($attribute, Yii::t('AdminModule.base', 'Base URL needs to begin with http:// or https://'));
}
}],
[['baseUrl'], 'url', 'pattern' => '/^{schemes}:\/\/([A-Z0-9][A-Z0-9_\-\.]*)+(?::\d{1,5})?(?:$|[?\/#])/i'],
[['baseUrl'], 'trim'],
['maintenanceModeInfo', 'safe'],
];
}