Skip to content

Commit cbfea1f

Browse files
ChristianVierthalerChristian Vierthaler
andauthored
feat(ZMSKVR-238): disallow emails with plus, tighter rules (#1642)
* Anpassung email pattern, kein "+" sowie strengere Regeln * weitere eingrenzung * clean(ZMSKVR-238): code * validation im zmscitizenapi angepasst * php-version fix --------- Co-authored-by: Christian Vierthaler <[email protected]>
1 parent 2fb2ee7 commit cbfea1f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

zmscitizenapi/src/Zmscitizenapi/Services/Core/ValidationService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ValidationService
2525
private const MIN_PROCESS_ID = 1;
2626
private const PHONE_PATTERN = '/^\+?[0-9]\d{6,14}$/';
2727
private const SERVICE_COUNT_PATTERN = '/^\d+$/';
28+
private const EMAIL_PATTERN = '/^(?!.*\.\.)(?!\.)(?!.*\.$)[^\s@+]+(?<!\.)@(?!\.)[^\s@+]+\.[^\s@]{2,}$/';
2829
private const MAX_FUTURE_DAYS = 365;
2930
// Maximum days in the future for appointments
3031

@@ -464,7 +465,7 @@ private static function isValidTimestamp(?int $timestamp): bool
464465

465466
private static function isValidEmail(?string $email): bool
466467
{
467-
return !empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
468+
return !empty($email) && preg_match(self::EMAIL_PATTERN, $email) === 1;
468469
}
469470

470471
private static function isValidTelephone(?string $telephone): bool

zmscitizenview/src/components/Appointment/CustomerInfo.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ const { isExpired, timeLeftString } = useReservationTimer();
204204
205205
const showErrorMessage = ref<boolean>(false);
206206
207-
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
207+
const emailPattern =
208+
/^(?!.*\.\.)(?!\.)(?!.*\.$)[^\s@+]+(?<!\.)@(?!\.)[^\s@+]+\.[^\s@]{2,}$/;
208209
const telephonPattern = /^\+?[0-9]\d{6,14}$/;
209210
210211
const errorMessageFirstName = computed(() => {

0 commit comments

Comments
 (0)