From 088fcf94493bf7d4b13735f0984676e44779e822 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Wed, 26 Sep 2012 09:19:43 +0000 Subject: [PATCH] Protect the download of documents against spurious blank lines coming from nowhere !! SVN:trunk[2217] --- pages/ajax.render.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pages/ajax.render.php b/pages/ajax.render.php index 3d96793794..382239a0c2 100644 --- a/pages/ajax.render.php +++ b/pages/ajax.render.php @@ -829,6 +829,7 @@ try catch (Exception $e) { echo $e->GetMessage(); + echo "

Debug trace:

".print_r($e->getTrace(), true)."

\n"; IssueLog::Error($e->getMessage()); } @@ -856,6 +857,12 @@ function DownloadDocument(WebPage $oPage, $sClass, $id, $sAttCode, $sContentDisp $oDocument = $oObj->Get($sAttCode); if (is_object($oDocument)) { + // Make sure there is NO output at all before our content, otherwise the document will be corrupted + $sPreviousContent = ob_get_clean(); + if (trim($sPreviousContent) != '') + { + IssueLog::Error("Output already started before downloading file:\nContent was:'$sPreviousContent'\n"); + } $oPage->SetContentType($oDocument->GetMimeType()); $oPage->SetContentDisposition($sContentDisposition,$oDocument->GetFileName()); $oPage->add($oDocument->GetData()); @@ -866,4 +873,4 @@ function DownloadDocument(WebPage $oPage, $sClass, $id, $sAttCode, $sContentDisp $oPage->p($e->getMessage()); } } -?> +?>