From b3c158619506f993fe94fa1f119de8481b3ef5d0 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Mon, 30 Sep 2013 23:07:03 +0200 Subject: Better handling of callback errors on request containing non-UTF8 Previously we reported being unable to correctly encode the error string; report the original error instead --- framework/Web/UI/ActiveControls/TActivePageAdapter.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index 5e86f8b8..d90d0997 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -347,7 +347,13 @@ class TCallbackErrorHandler extends TErrorHandler if($this->getApplication()->getMode()===TApplication::STATE_DEBUG) { $response = $this->getApplication()->getResponse(); - $trace = TJavaScript::jsonEncode($this->getExceptionStackTrace($exception)); + $trace = $this->getExceptionStackTrace($exception); + 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); } -- cgit v1.2.3