diff --git a/app/Models/Server.php b/app/Models/Server.php index df136c72bd..c5b66d9c61 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -884,6 +884,35 @@ public function services() return $this->hasMany(Service::class); } + public function port(): Attribute + { + return Attribute::make( + get: function ($value) { + return preg_replace('/[^0-9]/', '', $value); + } + ); + } + + public function user(): Attribute + { + return Attribute::make( + get: function ($value) { + $sanitizedValue = preg_replace('/[^A-Za-z0-9\-_]/', '', $value); + + return $sanitizedValue; + } + ); + } + + public function ip(): Attribute + { + return Attribute::make( + get: function ($value) { + return preg_replace('/[^0-9a-zA-Z.-]/', '', $value); + } + ); + } + public function getIp(): Attribute { return Attribute::make( diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index 42fea49b15..75db25b29e 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -3,15 +3,10 @@