From ffe56bcf9b378bef4aff50a212d61d581b6a3a16 Mon Sep 17 00:00:00 2001 From: Christiaan Goossens Date: Thu, 30 Mar 2017 18:32:19 +0200 Subject: [PATCH] Proxy fix --- index.php | 3 +-- src/Proxy.php | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 7669d00..7665182 100644 --- a/index.php +++ b/index.php @@ -28,10 +28,9 @@ if (PHP_SAPI == 'cli-server') { // something which should probably be served as a static file $url = parse_url($_SERVER['REQUEST_URI']); $file = __DIR__ . $url['path']; + if (is_file($file)) { return false; - } elseif (pathinfo($url['path'], PATHINFO_EXTENSION) !== "") { - return false; } } diff --git a/src/Proxy.php b/src/Proxy.php index b8f3ce3..03a7266 100644 --- a/src/Proxy.php +++ b/src/Proxy.php @@ -14,16 +14,19 @@ namespace Inforbank; -use Bat\MimeTypeTool; - class Proxy { public function __invoke($request, $response, $next) { $uri = $request->getUri(); $path = $uri->getPath(); - if (strpos($path, 'assets/') !== false) { - if (file_exists($path)) { + $pa = explode('assets/', $path, 2); + + if (isset($pa[1])) { + $path = __DIR__ . '/../assets/'.$pa[1]; + $path = realpath($path); + + if ($path) { $ext = pathinfo($path, PATHINFO_EXTENSION); $ext2Mime = array(