From 89ae1784dc77ea34f65cb6ff862a57f7241e4cfc Mon Sep 17 00:00:00 2001 From: David Balch Date: Mon, 15 Jun 2009 12:15:54 +0100 Subject: [PATCH] Run xhtml files through filters. --- lib/filelib.php | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/filelib.php b/lib/filelib.php index 92ba502..e912816 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -717,7 +717,8 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss @header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT'); @header('Pragma: '); - if (empty($CFG->disablebyteserving) && !$pathisstring && $mimetype != 'text/plain' && $mimetype != 'text/html') { + if (empty($CFG->disablebyteserving) && !$pathisstring && + $mimetype != 'text/plain' && $mimetype != 'text/html' && $mimetype != 'application/xhtml+xml') { @header('Accept-Ranges: bytes'); @@ -753,7 +754,7 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss } } } else { - /// Do not byteserve (disabled, strings, text and html files). + /// Do not byteserve (disabled, strings, text, html and xhtml files). @header('Accept-Ranges: none'); } } else { // Do not cache files in proxies and browsers @@ -770,9 +771,10 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss } if (empty($filter)) { - if ($mimetype == 'text/html' && !empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) { + if (($mimetype == 'text/html' || $mimetype == 'application/xhtml+xml') && + !empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) { //cookieless mode - rewrite links - @header('Content-Type: text/html'); + @header('Content-Type: '.$mimetype); $path = $pathisstring ? $path : implode('', file($path)); $path = sid_ob_rewrite($path); $filesize = strlen($path); @@ -790,7 +792,7 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss readfile_chunked($path); } } else { // Try to put the file through filters - if ($mimetype == 'text/html') { + if ($mimetype == 'text/html' || $mimetype == 'application/xhtml+xml') { $options = new object(); $options->noclean = true; $options->nocache = true; // temporary workaround for MDL-5136 @@ -804,7 +806,7 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss } @header('Content-Length: '.strlen($output)); - @header('Content-Type: text/html'); + @header('Content-Type: '.$mimetype); while (@ob_end_flush()); //flush the buffers - save memory and disable sid rewrite echo $output; // only filter text if filter all files is selected -- 1.5.4.3