diff --git a/app/Filament/Server/Resources/FileResource/Pages/ListFiles.php b/app/Filament/Server/Resources/FileResource/Pages/ListFiles.php index 2a25b94d4..0868860b8 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)) @@ -181,7 +181,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))); + } +}