Fix static file path handling for security
Use REQUEST_URI and parse_url to properly handle paths Prevent directory traversal with stricter sanitization
This commit is contained in:
parent
2994f7cf6d
commit
19bb105303
1 changed files with 2 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
// Serve static files from /app directory
|
||||
$file = $_GET['file'] ?? '';
|
||||
$requestUri = $_SERVER['REQUEST_URI'];
|
||||
$file = preg_replace('#^/app/#', '', parse_url($requestUri, PHP_URL_PATH));
|
||||
$file = str_replace(['../', '..\\'], '', $file); // Prevent directory traversal
|
||||
|
||||
// Map request paths to actual file paths
|
||||
|
|
Loading…
Add table
Reference in a new issue