From 4183c3abc370e427724df858798d8bdc31c5345a Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 31 Jul 2018 10:52:00 -0700 Subject: [PATCH] Strip leading/trailing whitespace from element titles fixes #3020 --- CHANGELOG-v3.md | 1 + src/base/Element.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index 017dc4dac15..84faa96ee77 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -21,6 +21,7 @@ - Structure operations now ensure that no other operations are being performed on the same structure, reducing the risk of corrupting the structure. ([#3148](https://github.com/craftcms/cms/issues/3148)) - The `{% js %}` tag now supports the following position params: `at POS_HEAD`, `at POS_BEGIN`, `at POS_END`, `on POS_READY`, and `on POS_LOAD` (e.g. `{% js at POS_END %}`). - Craft once again checks for `X-Forwarded-For` headers when determining the user’s IP. ([#3036](https://github.com/craftcms/cms/issues/3036)) +- Leading/trailing whitespace characters are now stripped from element titles on save. ([#3020](https://github.com/craftcms/cms/issues/3020)) ### Deprecated - Deprecated `craft\db\Connection::createFromConfig()`. `craft\helpers\App::dbConfig()` should be used instead. diff --git a/src/base/Element.php b/src/base/Element.php index f6d3b111925..c2bd45dcfd7 100644 --- a/src/base/Element.php +++ b/src/base/Element.php @@ -954,7 +954,7 @@ public function rules() ]; if (static::hasTitles()) { - $rules[] = [['title'], StringValidator::class, 'max' => 255, 'disallowMb4' => true, 'on' => [self::SCENARIO_DEFAULT, self::SCENARIO_LIVE]]; + $rules[] = [['title'], StringValidator::class, 'max' => 255, 'disallowMb4' => true, 'trim' => true, 'on' => [self::SCENARIO_DEFAULT, self::SCENARIO_LIVE]]; $rules[] = [['title'], 'required', 'on' => [self::SCENARIO_DEFAULT, self::SCENARIO_LIVE]]; }