diff --git a/ChangeLog b/ChangeLog index b608203228..551bd4450d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ phpMyAdmin - ChangeLog - bug #3596070 [status] localStorage broken in server status monitor - bug #3598736 [routines] Editing a procedure with special characters - bug #3600322 [core] Visualize GIS data throws Fatal Error +- bug #3599362 [core] Double-escaped error message 3.5.5.0 (2012-12-21) - bug #3563824 [export] Support Apache's mod_deflate diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index b6b9bf0d80..c07de6f2ad 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -84,6 +84,21 @@ class PMA_Error_Handler /** * Error handler - called when errors are triggered/occured * + * This calls the addError() function, escaping the error string + * + * @param integer $errno + * @param string $errstr + * @param string $errfile + * @param integer $errline + */ + public function handleError($errno, $errstr, $errfile, $errline) + { + $this->addError($errstr, $errno, $errfile, $errline, $escape=true); + } + + /** + * Add an error; can also be called directly (with or without escaping) + * * The following error types cannot be handled with a user defined function: * E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, * E_COMPILE_WARNING, @@ -96,11 +111,15 @@ class PMA_Error_Handler * @param string $errstr * @param string $errfile * @param integer $errline + * @param boolean $escape */ - public function handleError($errno, $errstr, $errfile, $errline) + public function addError($errstr, $errno, $errfile, $errline, $escape=true) { + if ($escape) { + $errstr = htmlspecialchars($errstr); + } // create error object - $error = new PMA_Error($errno, htmlspecialchars($errstr), $errfile, $errline); + $error = new PMA_Error($errno, $errstr, $errfile, $errline); // do not repeat errors $this->_errors[$error->getHash()] = $error; @@ -131,6 +150,7 @@ class PMA_Error_Handler } } + /** * log error to configured log facility * diff --git a/libraries/core.lib.php b/libraries/core.lib.php index 93be5fefb4..eb698ff18b 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -277,7 +277,12 @@ function PMA_warnMissingExtension($extension, $fatal = false, $extra = '') if ($fatal) { PMA_fatalError($message); } else { - trigger_error($message, E_USER_WARNING); + $GLOBALS['error_handler']->addError( + $message, + E_USER_WARNING, + '', + '', + $escape=false); } } diff --git a/test/libraries/core/PMA_warnMissingExtension_test.php b/test/libraries/core/PMA_warnMissingExtension_test.php index 1e11c73f04..6fcf0c72c0 100644 --- a/test/libraries/core/PMA_warnMissingExtension_test.php +++ b/test/libraries/core/PMA_warnMissingExtension_test.php @@ -15,11 +15,9 @@ require_once 'libraries/core.lib.php'; class PMA_warnMissingExtension_test extends PHPUnit_Framework_TestCase { - function testMissingExtention(){ - $ext = 'php_ext'; - $this->setExpectedException('PHPUnit_Framework_Error', - 'The [a@'.PMA_getPHPDocLink('book.' . $ext . '.php').'@Documentation][em]'.$ext.'[/em][/a] extension is missing. Please check your PHP configuration.'); - PMA_warnMissingExtension($ext); + protected function setUp() { + require_once './libraries/Error_Handler.class.php'; + $GLOBALS['error_handler'] = new PMA_Error_Handler(); } function testMissingExtentionFatal(){ @@ -47,13 +45,4 @@ class PMA_warnMissingExtension_test extends PHPUnit_Framework_TestCase $this->assertGreaterThan(0, strpos($printed, $warn)); } - - function testMissingExtentionWithExtra(){ - $ext = 'php_ext'; - $extra = 'Appended Extra String'; - $this->setExpectedException('PHPUnit_Framework_Error', - 'The [a@'.PMA_getPHPDocLink('book.' . $ext . '.php').'@Documentation][em]'.$ext.'[/em][/a] extension is missing. Please check your PHP configuration.'.' '.$extra); - PMA_warnMissingExtension($ext, false, $extra); - $this->assertTrue(true); - } }