Skip to content

Commit 5dbcddc

Browse files
committed
Decode URL fragments correctly before sending to the daemon; ref pterodactyl#2040 ref pterodactyl#2038
1 parent 57f7aa1 commit 5dbcddc

File tree

1 file changed

+5
-44
lines changed

1 file changed

+5
-44
lines changed

app/Repositories/Wings/DaemonFileRepository.php

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,13 @@
22

33
namespace Pterodactyl\Repositories\Wings;
44

5-
use stdClass;
6-
use Exception;
75
use Webmozart\Assert\Assert;
86
use Pterodactyl\Models\Server;
97
use Psr\Http\Message\ResponseInterface;
108
use Pterodactyl\Exceptions\Http\Server\FileSizeTooLargeException;
119

1210
class DaemonFileRepository extends DaemonRepository
1311
{
14-
/**
15-
* Return stat information for a given file.
16-
*
17-
* @param string $path
18-
* @return \stdClass
19-
*
20-
* @throws \Exception
21-
* @throws \GuzzleHttp\Exception\TransferException
22-
*/
23-
public function getFileStat(string $path): stdClass
24-
{
25-
throw new Exception('Function not implemented.');
26-
}
27-
2812
/**
2913
* Return the contents of a given file.
3014
*
@@ -55,29 +39,6 @@ public function getContent(string $path, int $notLargerThan = null): string
5539
return $response->getBody()->__toString();
5640
}
5741

58-
/**
59-
* Returns a stream of a file's contents back to the calling function to allow
60-
* proxying the request through the Panel rather than needing a direct call to
61-
* the Daemon in order to work.
62-
*
63-
* @param string $path
64-
* @return \Psr\Http\Message\ResponseInterface
65-
*/
66-
public function streamContent(string $path): ResponseInterface
67-
{
68-
Assert::isInstanceOf($this->server, Server::class);
69-
70-
$response = $this->getHttpClient()->get(
71-
sprintf('/api/servers/%s/files/contents', $this->server->uuid),
72-
[
73-
'query' => ['file' => $path, 'download' => true],
74-
'stream' => true,
75-
]
76-
);
77-
78-
return $response;
79-
}
80-
8142
/**
8243
* Save new contents to a given file. This works for both creating and updating
8344
* a file.
@@ -138,8 +99,8 @@ public function createDirectory(string $name, string $path): ResponseInterface
13899
sprintf('/api/servers/%s/files/create-directory', $this->server->uuid),
139100
[
140101
'json' => [
141-
'name' => $name,
142-
'path' => $path,
102+
'name' => urldecode($name),
103+
'path' => urldecode($path),
143104
],
144105
]
145106
);
@@ -160,8 +121,8 @@ public function renameFile(string $from, string $to): ResponseInterface
160121
sprintf('/api/servers/%s/files/rename', $this->server->uuid),
161122
[
162123
'json' => [
163-
'rename_from' => $from,
164-
'rename_to' => $to,
124+
'rename_from' => urldecode($from),
125+
'rename_to' => urldecode($to),
165126
],
166127
]
167128
);
@@ -181,7 +142,7 @@ public function copyFile(string $location): ResponseInterface
181142
sprintf('/api/servers/%s/files/copy', $this->server->uuid),
182143
[
183144
'json' => [
184-
'location' => $location,
145+
'location' => urldecode($location),
185146
],
186147
]
187148
);

0 commit comments

Comments
 (0)