Skip to content
Snippets Groups Projects
Commit 9b709fa9 authored by Thomas Müller's avatar Thomas Müller
Browse files

Merge pull request #635 from owncloud/ob_end

provide a safe way to end output buffering
parents c38a75e0 bcb27c81
Branches
No related tags found
No related merge requests found
...@@ -27,7 +27,7 @@ $RUNTIME_APPTYPES=array('filesystem', 'authentication', 'logging'); ...@@ -27,7 +27,7 @@ $RUNTIME_APPTYPES=array('filesystem', 'authentication', 'logging');
OC_App::loadApps($RUNTIME_APPTYPES); OC_App::loadApps($RUNTIME_APPTYPES);
ob_end_clean(); OC_Util::obEnd();
// Backends // Backends
$authBackend = new OC_Connector_Sabre_Auth(); $authBackend = new OC_Connector_Sabre_Auth();
......
...@@ -44,5 +44,5 @@ header('Content-Disposition: attachment; filename="'.basename($filename).'"'); ...@@ -44,5 +44,5 @@ header('Content-Disposition: attachment; filename="'.basename($filename).'"');
OCP\Response::disableCaching(); OCP\Response::disableCaching();
header('Content-Length: '.OC_Filesystem::filesize($filename)); header('Content-Length: '.OC_Filesystem::filesize($filename));
@ob_end_clean(); OC_Util::obEnd();
OC_Filesystem::readfile( $filename ); OC_Filesystem::readfile( $filename );
...@@ -32,7 +32,7 @@ class OC_EventSource{ ...@@ -32,7 +32,7 @@ class OC_EventSource{
private $fallBackId=0; private $fallBackId=0;
public function __construct() { public function __construct() {
@ob_end_clean(); OC_Util::obEnd();
header('Cache-Control: no-cache'); header('Cache-Control: no-cache');
$this->fallback=isset($_GET['fallback']) and $_GET['fallback']=='true'; $this->fallback=isset($_GET['fallback']) and $_GET['fallback']=='true';
if($this->fallback) { if($this->fallback) {
......
...@@ -195,7 +195,7 @@ class OC_Files { ...@@ -195,7 +195,7 @@ class OC_Files {
$zip=false; $zip=false;
$filename=$dir.'/'.$files; $filename=$dir.'/'.$files;
} }
@ob_end_clean(); OC_Util::obEnd();
if($zip or OC_Filesystem::is_readable($filename)) { if($zip or OC_Filesystem::is_readable($filename)) {
header('Content-Disposition: attachment; filename="'.basename($filename).'"'); header('Content-Disposition: attachment; filename="'.basename($filename).'"');
header('Content-Transfer-Encoding: binary'); header('Content-Transfer-Encoding: binary');
......
...@@ -195,7 +195,7 @@ class OC_FilesystemView { ...@@ -195,7 +195,7 @@ class OC_FilesystemView {
return $this->basicOperation('filesize', $path); return $this->basicOperation('filesize', $path);
} }
public function readfile($path) { public function readfile($path) {
@ob_end_clean(); OC_Util::obEnd();
$handle=$this->fopen($path, 'rb'); $handle=$this->fopen($path, 'rb');
if ($handle) { if ($handle) {
$chunkSize = 8192;// 8 MB chunks $chunkSize = 8192;// 8 MB chunks
......
...@@ -610,6 +610,15 @@ class OC_Util { ...@@ -610,6 +610,15 @@ class OC_Util {
} }
/**
* clear all levels of output buffering
*/
public static function obEnd(){
while (ob_get_level()) {
ob_end_clean();
}
}
/** /**
* @brief Generates a cryptographical secure pseudorandom string * @brief Generates a cryptographical secure pseudorandom string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment