Files
pterodactyl-panel/app/Rules/UserEmail.php
T

28 lines
695 B
PHP
Raw Normal View History

2026-10-05 18:10:18 -04:00
<?php
declare(strict_types=1);
namespace Pterodactyl\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class UserEmail implements ValidationRule
{
/**
* Validate that the local part of an email address does not start with a dash, quoted
* or not, so the address can never be read as a command-line option.
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (! is_string($value)) {
return;
}
$local = mb_trim(explode('@', $value, 2)[0], '"');
if (str_starts_with($local, '-')) {
$fail('The :attribute must not start with a dash.');
}
}
}