From 1f61f9433b471e4ae05c8d5cf608eecaaace2ed8 Mon Sep 17 00:00:00 2001 From: notCharles Date: Thu, 4 Sep 2025 16:49:53 -0400 Subject: [PATCH] url encode --- .../Server/Resources/FileResource/Pages/ListFiles.php | 8 ++++---- app/helpers.php | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Filament/Server/Resources/FileResource/Pages/ListFiles.php b/app/Filament/Server/Resources/FileResource/Pages/ListFiles.php index 6fac1498b..4cba86046 100644 --- a/app/Filament/Server/Resources/FileResource/Pages/ListFiles.php +++ b/app/Filament/Server/Resources/FileResource/Pages/ListFiles.php @@ -114,7 +114,7 @@ class ListFiles extends ListRecords return null; } - return $file->canEdit() ? EditFiles::getUrl(['path' => join_paths($this->path, $file->name)]) : null; + return $file->canEdit() ? EditFiles::getUrl(['path' => encode_path(join_paths($this->path, $file->name))]) : null; }) ->actions([ Action::make('view') @@ -122,12 +122,12 @@ class ListFiles extends ListRecords ->label(trans('server/file.actions.open')) ->icon('tabler-eye') ->visible(fn (File $file) => $file->is_directory) - ->url(fn (File $file) => self::getUrl(['path' => join_paths($this->path, $file->name)])), + ->url(fn (File $file) => self::getUrl(['path' => encode_path(join_paths($this->path, $file->name))])), EditAction::make('edit') ->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_READ_CONTENT, $server)) ->icon('tabler-edit') ->visible(fn (File $file) => $file->canEdit()) - ->url(fn (File $file) => EditFiles::getUrl(['path' => join_paths($this->path, $file->name)])), + ->url(fn (File $file) => EditFiles::getUrl(['path' => encode_path(join_paths($this->path, $file->name))])), ActionGroup::make([ Action::make('rename') ->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server)) @@ -182,7 +182,7 @@ class ListFiles extends ListRecords ->label(trans('server/file.actions.download')) ->icon('tabler-download') ->visible(fn (File $file) => $file->is_file) - ->url(fn (File $file) => DownloadFiles::getUrl(['path' => join_paths($this->path, $file->name)]), true), + ->url(fn (File $file) => DownloadFiles::getUrl(['path' => encode_path(join_paths($this->path, $file->name))]), true), Action::make('move') ->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server)) ->label(trans('server/file.actions.move.title')) diff --git a/app/helpers.php b/app/helpers.php index 9f958a6e6..88e309f78 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -110,3 +110,10 @@ if (!function_exists('format_number')) { } } } + +if (!function_exists('encode_path')) { + function encode_path(string $path): string + { + return implode('/', array_map('rawurlencode', explode('/', $path))); + } +}