From 4340b1406780348c5545b33819e97eed0d78f24f Mon Sep 17 00:00:00 2001 From: Conner Harkness Date: Thu, 21 Aug 2025 07:10:58 -0600 Subject: [PATCH] Serve only valid mime types --- index.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 8f1e0ba..aa0db86 100644 --- a/index.php +++ b/index.php @@ -62,6 +62,7 @@ if (is_file($strTargetFilePath)) { + $intValid = 0; $varMimeTypes = array( array("/\.css$/", "text/css"), array("/\.js$/", "application/javascript"), @@ -72,12 +73,18 @@ foreach ($varMimeTypes as $varMimeType) if (preg_match($varMimeType[0], $strTargetFilePath)) + { header("Content-Type: {$varMimeType[1]}"); + $intValid = 1; + } - ob_clean(); - echo file_get_contents($strTargetFilePath); - ob_end_flush(); - exit; + if ($intValid) + { + ob_clean(); + echo file_get_contents($strTargetFilePath); + ob_end_flush(); + exit; + } } }