Files
pterodactyl-panel/app/Rules/UserEmail.php
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

28 lines
695 B
PHP

<?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.');
}
}
}