Fix email masking: show at least half the local part (min 4 chars)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro
2026-07-14 18:51:36 +00:00
co-authored by Claude Sonnet 4.6
parent bd421af05d
commit ad9d1761d2
+3 -2
View File
@@ -1186,8 +1186,9 @@ class TelegramBotService
private function maskEmail(string $email): string
{
[$local, $domain] = explode('@', $email, 2);
$visible = mb_substr($local, 0, min(3, mb_strlen($local)));
return $visible . str_repeat('*', max(0, mb_strlen($local) - 3)) . '@' . $domain;
$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;
}
private function createMPPreference(string $titulo, int $valor, string $ref): ?string