From 00d195c7dd4ff2c92a2254779dc303a04d76c364 Mon Sep 17 00:00:00 2001 From: Spitfire Date: Thu, 2 Nov 2023 11:26:11 -0600 Subject: [PATCH 1/2] Fixed validation error on Vanity URLS --- .../{Calendars/Api => Campaign}/VanityController.php | 2 +- app/Rules/Vanity.php | 4 ++++ lang/en/campaigns/vanity.php | 1 + routes/campaigns/campaign.php | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) rename app/Http/Controllers/{Calendars/Api => Campaign}/VanityController.php (90%) diff --git a/app/Http/Controllers/Calendars/Api/VanityController.php b/app/Http/Controllers/Campaign/VanityController.php similarity index 90% rename from app/Http/Controllers/Calendars/Api/VanityController.php rename to app/Http/Controllers/Campaign/VanityController.php index 6b7749dcbd..8800a4c96a 100644 --- a/app/Http/Controllers/Calendars/Api/VanityController.php +++ b/app/Http/Controllers/Campaign/VanityController.php @@ -1,6 +1,6 @@ $attribute])); + } + if (!preg_match('`[a-zA-Z]+`', $value)) { $fail(__('campaigns/vanity.rule', ['field' => $attribute])); } diff --git a/lang/en/campaigns/vanity.php b/lang/en/campaigns/vanity.php index 6ce026f4ca..5ed95bb485 100644 --- a/lang/en/campaigns/vanity.php +++ b/lang/en/campaigns/vanity.php @@ -4,5 +4,6 @@ 'available' => 'The name :vanity is available!', 'helper' => 'Make the campaign stand out with a unique name in the URL. For example, instead of showing up as :default, have every page\'s url in the campaign show up as :example. This field can only be set once and is permanent. Learn more about this feature in our :learn-more.', 'rule' => 'The :field field needs at least one alphabetical character.', + 'rule2' => 'The :field field doesn\'t allow the following character: /.', 'set' => 'The campaign\'s vanity URL is permanently set to :vanity.', ]; diff --git a/routes/campaigns/campaign.php b/routes/campaigns/campaign.php index 5bb148ee48..1dfcbb69ed 100644 --- a/routes/campaigns/campaign.php +++ b/routes/campaigns/campaign.php @@ -170,4 +170,4 @@ Route::get('/w/{campaign}/confirm-delete', [\App\Http\Controllers\ConfirmController::class, 'index'])->name('confirm-delete'); -Route::post('/w/{campaign}/vanity-validate', [\App\Http\Controllers\Calendars\Api\VanityController::class, 'index'])->name('campaign.vanity-validate'); +Route::post('/w/{campaign}/vanity-validate', [\App\Http\Controllers\Campaign\VanityController::class, 'index'])->name('campaign.vanity-validate'); From 81a88293f37dc32d619344827943ebc3396cf47e Mon Sep 17 00:00:00 2001 From: spitfire305 Date: Thu, 2 Nov 2023 17:28:10 +0000 Subject: [PATCH 2/2] Fix styling --- app/Http/Controllers/Crud/CalendarController.php | 2 -- app/Rules/Vanity.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Http/Controllers/Crud/CalendarController.php b/app/Http/Controllers/Crud/CalendarController.php index ee3393bd44..ffd0b84156 100644 --- a/app/Http/Controllers/Crud/CalendarController.php +++ b/app/Http/Controllers/Crud/CalendarController.php @@ -9,8 +9,6 @@ use App\Models\Campaign; use App\Sanitizers\CalendarSanitizer; use App\Traits\TreeControllerTrait; -use App\Http\Requests\ValidateReminderLength; -use App\Services\LengthValidatorService; class CalendarController extends CrudController { diff --git a/app/Rules/Vanity.php b/app/Rules/Vanity.php index 824e9beea6..f624d06396 100644 --- a/app/Rules/Vanity.php +++ b/app/Rules/Vanity.php @@ -15,7 +15,7 @@ class Vanity implements ValidationRule public function validate(string $attribute, mixed $value, Closure $fail): void { $value = trim($value); - if (strpos($value, '/')) { + if (mb_strpos($value, '/')) { $fail(__('campaigns/vanity.rule2', ['field' => $attribute])); }