Skip to content

Commit 3340ee7

Browse files
committed
Fix bad encoding when handling files; closes pterodactyl#2399
1 parent 711efe3 commit 3340ee7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/Http/Controllers/Api/Client/Servers/FileController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function directory(ListFilesRequest $request, Server $server): array
7070
{
7171
$contents = $this->fileRepository
7272
->setServer($server)
73-
->getDirectory($request->get('directory') ?? '/');
73+
->getDirectory(urlencode($request->get('directory') ?? '/'));
7474

7575
return $this->fractal->collection($contents)
7676
->transformWith($this->getTransformer(FileObjectTransformer::class))
@@ -91,7 +91,7 @@ public function contents(GetFileContentsRequest $request, Server $server): Respo
9191
{
9292
return new Response(
9393
$this->fileRepository->setServer($server)->getContent(
94-
$request->get('file'), config('pterodactyl.files.max_edit_size')
94+
urlencode($request->get('file')), config('pterodactyl.files.max_edit_size')
9595
),
9696
Response::HTTP_OK,
9797
['Content-Type' => 'text/plain']

app/Repositories/Wings/DaemonFileRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ public function createDirectory(string $name, string $path): ResponseInterface
117117
sprintf('/api/servers/%s/files/create-directory', $this->server->uuid),
118118
[
119119
'json' => [
120-
'name' => urldecode($name),
121-
'path' => urldecode($path),
120+
'name' => $name,
121+
'path' => $path,
122122
],
123123
]
124124
);
@@ -172,7 +172,7 @@ public function copyFile(string $location): ResponseInterface
172172
sprintf('/api/servers/%s/files/copy', $this->server->uuid),
173173
[
174174
'json' => [
175-
'location' => urldecode($location),
175+
'location' => $location,
176176
],
177177
]
178178
);

0 commit comments

Comments
 (0)