make sure plugin name & author only contain alpha num and spaces

This commit is contained in:
Boy132 2025-11-10 09:11:42 +01:00
parent 8882f9b6bb
commit 4d33294951

View File

@ -29,7 +29,9 @@ class MakePluginCommand extends Command
public function handle(): void
{
$name = Str::ascii($this->option('name') ?? $this->ask('Name'));
$name = $this->option('name') ?? $this->ask('Name');
$name = preg_replace('/[^A-Za-z0-9 ]/', '', Str::ascii($name));
$id = Str::slug($name);
if ($this->filesystem->exists(plugin_path($id))) {
@ -38,7 +40,8 @@ class MakePluginCommand extends Command
return;
}
$author = Str::ascii($this->option('author') ?? $this->ask('Author', cache('plugin.author')));
$author = $this->option('author') ?? $this->ask('Author', cache('plugin.author'));
$author = preg_replace('/[^A-Za-z0-9 ]/', '', Str::ascii($author));
cache()->forever('plugin.author', $author);
$namespace = Str::studly($author) . '\\' . Str::studly($name);