mirror of
https://github.com/pelican-dev/panel.git
synced 2025-09-08 23:08:37 +02:00
Encode file path in url (#1661)
This commit is contained in:
parent
079eaed010
commit
2952e22619
@ -114,7 +114,7 @@ class ListFiles extends ListRecords
|
|||||||
return null;
|
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([
|
->actions([
|
||||||
Action::make('view')
|
Action::make('view')
|
||||||
@ -122,12 +122,12 @@ class ListFiles extends ListRecords
|
|||||||
->label(trans('server/file.actions.open'))
|
->label(trans('server/file.actions.open'))
|
||||||
->icon('tabler-eye')
|
->icon('tabler-eye')
|
||||||
->visible(fn (File $file) => $file->is_directory)
|
->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')
|
EditAction::make('edit')
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_READ_CONTENT, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_READ_CONTENT, $server))
|
||||||
->icon('tabler-edit')
|
->icon('tabler-edit')
|
||||||
->visible(fn (File $file) => $file->canEdit())
|
->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([
|
ActionGroup::make([
|
||||||
Action::make('rename')
|
Action::make('rename')
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
||||||
@ -181,7 +181,7 @@ class ListFiles extends ListRecords
|
|||||||
->label(trans('server/file.actions.download'))
|
->label(trans('server/file.actions.download'))
|
||||||
->icon('tabler-download')
|
->icon('tabler-download')
|
||||||
->visible(fn (File $file) => $file->is_file)
|
->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')
|
Action::make('move')
|
||||||
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
|
||||||
->label(trans('server/file.actions.move.title'))
|
->label(trans('server/file.actions.move.title'))
|
||||||
|
@ -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)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user