From d9436919bdd937fdd254b22c2d55745e5a7ddcdc Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Sat, 9 Apr 2011 16:34:49 -0400 Subject: [PATCH] Fixed missing Content-Type headers when loading internal static assets (e.g. /__pickles/css/reset.css) --- classes/Controller.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/Controller.php b/classes/Controller.php index 2be97d5..62a4d81 100644 --- a/classes/Controller.php +++ b/classes/Controller.php @@ -60,14 +60,18 @@ class Controller extends Object } // Catches requests to PICKLES core files and passes them through - if (preg_match('/^__pickles\/(css|js)\/.+$/', $_REQUEST['request'])) + if (preg_match('/^__pickles\/(css|js)\/.+$/', $_REQUEST['request'], $matches)) { // Checks that the file exists - $file = str_replace('__pickles', PICKLES_PATH, $_REQUEST['request']); + $file = str_replace('__pickles/', PICKLES_PATH, $_REQUEST['request']); if (file_exists($file)) { // Sets the pass thru flag and dumps the data $this->passthru = true; + + // This is somewhat hacky, but mime_content_type() is deprecated and finfo_file() is only 5.3+ + header('Content-Type: text/' . ($matches[1] == 'js' ? 'javascript' : $matches[1])); + exit(file_get_contents($file)); } }