Skip to content

Commit 05f41a2

Browse files
committed
Don't trim strings on file manager endpoints; ref pterodactyl#4081
1 parent d0b6ae0 commit 05f41a2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/Providers/RouteServiceProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,26 @@
66
use Illuminate\Support\Facades\Route;
77
use Illuminate\Cache\RateLimiting\Limit;
88
use Illuminate\Support\Facades\RateLimiter;
9+
use Pterodactyl\Http\Middleware\TrimStrings;
910
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
1011

1112
class RouteServiceProvider extends ServiceProvider
1213
{
14+
protected const FILE_PATH_REGEX = '/^\/api\/client\/servers\/([a-z0-9-]{36})\/files(\/?$|\/(.)*$)/i';
15+
1316
/**
1417
* Define your route model bindings, pattern filters, etc.
1518
*/
1619
public function boot()
1720
{
1821
$this->configureRateLimiting();
1922

23+
// Disable trimming string values when requesting file information — it isn't helpful
24+
// and messes up the ability to actually open a directory that ends with a space.
25+
TrimStrings::skipWhen(function (Request $request) {
26+
return preg_match(self::FILE_PATH_REGEX, $request->getPathInfo()) === 1;
27+
});
28+
2029
$this->routes(function () {
2130
Route::middleware(['web', 'csrf'])->group(function () {
2231
Route::middleware('auth')->group(base_path('routes/base.php'));

0 commit comments

Comments
 (0)