From 945b9d501c5a7b46b59c854c2bbe8d261bfd63a8 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 24 Feb 2010 12:47:55 +1300 Subject: [PATCH] Provide passthru on icons, images, css and js files. In Chrome it requests the favicon (for example) very frequently which was causing a prompt for authentication where there was a poorly considered regex in the rewrite rules. I think this is a good backup to the rewrite rules to pass through on such files. --- htdocs/caldav.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/caldav.php b/htdocs/caldav.php index 0f8719d0..5d068f4c 100644 --- a/htdocs/caldav.php +++ b/htdocs/caldav.php @@ -8,6 +8,17 @@ * @copyright Catalyst .Net Ltd, Morphoss Ltd * @license http://gnu.org/copyleft/gpl.html GNU GPL v2 or later */ +if ( preg_match( '{^(/favicon.ico|davical.css|(images|js|css)/.+)$}', $_SERVER['PATH_INFO'], $matches ) ) { + $filename = $_SERVER['DOCUMENT_ROOT'] . preg_replace('{(\.\.|\\\\)}', '', $matches[1]); + $fh = @fopen($matches[1],'r'); + if ( ! $fh ) { + @header( sprintf("HTTP/1.1 %d %s", 404, 'Not found') ); + } + else { + fpassthru($fh); + } + exit(0); +} require_once('../inc/always.php'); // dbg_error_log( 'caldav', ' User agent: %s', ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'Unfortunately Mulberry does not send a "User-agent" header with its requests :-(')) ); // dbg_log_array( 'headers', '_SERVER', $_SERVER, true );