From 30fc8c0f1b13d59efe5a970e4f0ff296c5bae6b9 Mon Sep 17 00:00:00 2001 From: Lizandro Date: Tue, 14 Jul 2026 19:34:14 +0000 Subject: [PATCH] fix: email mask shows max 4 chars instead of half the local part lizandro.guarnizo (17 chars) was showing 'lizandro.' (9 chars including the dot) because ceil(17/2)=9. Now always shows exactly min(4, len) chars: 'liza*************@domain' Co-Authored-By: Claude Sonnet 4.6 --- app/Http/Livewire/Chat/PublicChat.php | 5 +++-- app/Services/TelegramBotService.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Http/Livewire/Chat/PublicChat.php b/app/Http/Livewire/Chat/PublicChat.php index a3991f9..0b2f49e 100755 --- a/app/Http/Livewire/Chat/PublicChat.php +++ b/app/Http/Livewire/Chat/PublicChat.php @@ -331,8 +331,9 @@ class PublicChat extends Component private function enmascararEmail(string $email): string { [$local, $dominio] = explode('@', $email, 2); - $visible = mb_substr($local, 0, min(3, mb_strlen($local))); - return $visible . str_repeat('*', max(0, mb_strlen($local) - 3)) . '@' . $dominio; + $n = min(4, mb_strlen($local)); + $visible = mb_substr($local, 0, $n); + return $visible . str_repeat('*', max(0, mb_strlen($local) - $n)) . '@' . $dominio; } // ───────────────────────────────────────────────────────── diff --git a/app/Services/TelegramBotService.php b/app/Services/TelegramBotService.php index d6a900c..9255c65 100644 --- a/app/Services/TelegramBotService.php +++ b/app/Services/TelegramBotService.php @@ -1366,8 +1366,8 @@ class TelegramBotService { [$local, $domain] = explode('@', $email, 2); $len = mb_strlen($local); - $visible = max(4, (int) ceil($len / 2)); // muestra la mitad, mínimo 4 caracteres - return mb_substr($local, 0, min($visible, $len)) . str_repeat('*', max(0, $len - $visible)) . '@' . $domain; + $visible = min(4, $len); // siempre 4 caracteres máximo + return mb_substr($local, 0, $visible) . str_repeat('*', max(0, $len - $visible)) . '@' . $domain; } private function createMPPreference(string $titulo, int $valor, string $ref): ?string