diff options
author | Fabio Bas <ctrlaltca@gmail.com> | 2014-02-19 19:13:49 +0100 |
---|---|---|
committer | David <ottodavid@gmx.net> | 2014-08-21 17:21:25 +0200 |
commit | 83393f6c81455ae54467aca067077a98f1a41881 (patch) | |
tree | 3831cc96444a8754a6c2a9564eab17921324c2ca /framework/Web | |
parent | a6edfca52702da817685a37c8bfb71478964298c (diff) |
Avoid an exception loop on callback error when headers have already been sent; send error trace in the body, since headers are limited in size
(cherry picked from commit 0700ac0eb6d1cb884ca6d568f798ed785c38e908)
Diffstat (limited to 'framework/Web')
-rw-r--r-- | framework/Web/UI/ActiveControls/TActivePageAdapter.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index 60670c09..cc32376a 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -148,7 +148,6 @@ class TActivePageAdapter extends TControlAdapter { Prado::trace("ActivePage redirect()",'System.Web.UI.ActiveControls.TActivePageAdapter'); $this->appendContentPart($this->getResponse(), self::CALLBACK_REDIRECT, $url); - //$this->getResponse()->appendHeader(self::CALLBACK_REDIRECT.': '.$url); } /** @@ -174,7 +173,6 @@ class TActivePageAdapter extends TControlAdapter $data = TJavaScript::jsonEncode($responseData); $this->appendContentPart($response, self::CALLBACK_DATA_HEADER, $data); - //$response->appendHeader(self::CALLBACK_DATA_HEADER.': '.$data); } } @@ -185,7 +183,6 @@ class TActivePageAdapter extends TControlAdapter { $pagestate = $this->getPage()->getClientState(); $this->appendContentPart($response, self::CALLBACK_PAGESTATE_HEADER, $pagestate); - //$response->appendHeader(self::CALLBACK_PAGESTATE_HEADER.': '.$pagestate); } } @@ -204,7 +201,6 @@ class TActivePageAdapter extends TControlAdapter $executeJavascript = $this->getCallbackClientHandler()->getClientFunctionsToExecute(); $actions = TJavaScript::jsonEncode($executeJavascript); $this->appendContentPart($response, self::CALLBACK_ACTION_HEADER, $actions); - //$response->appendHeader(self::CALLBACK_ACTION_HEADER.': '.$actions); $cs = $this->Page->getClientScript(); @@ -294,7 +290,7 @@ class TActivePageAdapter extends TControlAdapter } /** - * Gets callback parameter. + * Gets callback parameter. * @return string postback event parameter */ public function getCallbackEventParameter() @@ -353,14 +349,22 @@ class TCallbackErrorHandler extends TErrorHandler { $response = $this->getApplication()->getResponse(); $trace = $this->getExceptionStackTrace($exception); + // avoid error on non-utf8 strings try { $trace = TJavaScript::jsonEncode($trace); } catch (Exception $e) { // strip everythin not 7bit ascii $trace = preg_replace('/[^(\x20-\x7F)]*/','', serialize($trace)); } - $response->setStatusCode(500, 'Internal Server Error'); - $response->appendHeader(TActivePageAdapter::CALLBACK_ERROR_HEADER.': '.$trace); + + // avoid exception loop if headers have already been sent + try { + $response->setStatusCode(500, 'Internal Server Error'); + } catch (Exception $e) { } + + $content = $response->createHtmlWriter(); + $content->getWriter()->setBoundary(TActivePageAdapter::CALLBACK_ERROR_HEADER); + $content->write($trace); } else { |