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, '-')) {
|
2026-11-23 14:51:03 +00:00
|
|
|
$fail(__('validation.internal.email_leading_dash'));
|
2026-10-05 18:10:18 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|