From 72da92bc590f9ae9212b17daf9e333710370884d Mon Sep 17 00:00:00 2001 From: David Balch Date: Mon, 27 Apr 2009 16:24:52 +0100 Subject: [PATCH] Enable text filtering on XHTML files. --- lib/filelib.php | 19 ++++++++++--------- 1 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/filelib.php b/lib/filelib.php index a61c41f..f864eb1 100644 --- a/lib/filelib.php +++ b/lib/filelib.php @@ -1024,7 +1024,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'); @@ -1078,9 +1079,9 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss } if (empty($filter)) { - if ($mimetype == 'text/html' && !empty($CFG->usesid)) { + if (($mimetype == 'text/html' || $mimetype == 'application/xhtml+xml') && !empty($CFG->usesid)) { //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); @@ -1098,7 +1099,7 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss @readfile($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 @@ -1112,7 +1113,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 @@ -1265,9 +1266,9 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl if (empty($filter)) { $filtered = false; - if ($mimetype == 'text/html' && !empty($CFG->usesid)) { + if (($mimetype == 'text/html' || $mimetype == 'application/xhtml+xml') && !empty($CFG->usesid)) { //cookieless mode - rewrite links - @header('Content-Type: text/html'); + @header('Content-Type: '.$mimetype); $text = $stored_file->get_content(); $text = sid_ob_rewrite($text); $filesize = strlen($text); @@ -1286,7 +1287,7 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl } } 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 @@ -1299,7 +1300,7 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl } @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.6.3