diff --git a/libraries/DatabaseInterface.php b/libraries/DatabaseInterface.php index c36f9399dc..114132ee9c 100644 --- a/libraries/DatabaseInterface.php +++ b/libraries/DatabaseInterface.php @@ -206,30 +206,9 @@ class DatabaseInterface // Get and slightly format backtrace, this is used // in the javascript console. // Strip call to _dbgQuery - $dbgInfo['trace'] = array_slice(debug_backtrace(), 1); - foreach ($dbgInfo['trace'] as $key => $step) { - if (isset($step['file'])) { - $dbgInfo['trace'][$key]['file'] = Error::relPath($step['file']); - } - // We don't need object value in console and it's too big - if (isset($step['object'])) { - unset($dbgInfo['trace'][$key]['object']); - } - // Convert args to string as that's what the client would do anyway - if (isset($step['args'])) { - $simplified = array(); - foreach ($step['args'] as $akey => $aval) { - if (is_object($aval)) { - $simplified[$akey] = ''; - } elseif (is_array($aval)) { - $simplified[$akey] = var_export($aval, true); - } else { - $simplified[$akey] = $aval; - } - } - $dbgInfo['trace'][$key]['args'] = $simplified; - } - } + $dbgInfo['trace'] = Error::processBacktrace( + array_slice(debug_backtrace(), 1) + ); $dbgInfo['hash'] = md5($query); $_SESSION['debug']['queries'][] = $dbgInfo; diff --git a/libraries/Error.php b/libraries/Error.php index 947bf998bc..5caec03852 100644 --- a/libraries/Error.php +++ b/libraries/Error.php @@ -106,6 +106,41 @@ class Error extends Message $this->setBacktrace($backtrace); } + /** + * Process backtrace to avoid path disclossures, objects and so on + * + * @param array $backtrace backtrace + * + * @return array + */ + public static function processBacktrace($backtrace) + { + $result = array(); + + $members = array('file', 'line', 'function', 'class', 'type'); + + foreach ($backtrace as $idx => $step) { + /* Create new backtrace entry */ + $result[$idx] = array(); + + /* Store members we want */ + foreach ($members as $name) { + if (isset($step[$name])) { + $result[$idx][$name] = $step[$name]; + } + } + + /* Store simplified args */ + if (isset($step['args'])) { + foreach ($step['args'] as $key => $arg) { + $result[$idx]['args'][$key] = Error::getArg($arg, $step['function']); + } + } + } + + return $result; + } + /** * sets PMA\libraries\Error::$_backtrace * @@ -117,28 +152,7 @@ class Error extends Message */ public function setBacktrace($backtrace) { - $this->backtrace = array(); - - $members = array('file', 'line', 'function', 'class', 'type'); - - foreach ($backtrace as $idx => $step) { - /* Create new backtrace entry */ - $this->backtrace[$idx] = array(); - - /* Store members we want */ - foreach ($members as $name) { - if (isset($step[$name])) { - $this->backtrace[$idx][$name] = $step[$name]; - } - } - - /* Store simplified args */ - if (isset($step['args'])) { - foreach ($step['args'] as $key => $arg) { - $this->backtrace[$idx]['args'][$key] = Error::getArg($arg, $step['function']); - } - } - } + $this->backtrace = Error::processBacktrace($backtrace); } /** @@ -379,6 +393,8 @@ class Error extends Message } elseif (is_scalar($arg)) { $retval .= getType($arg) . ' ' . htmlspecialchars(var_export($arg, true)); + } elseif (is_object($arg)) { + $retval .= ''; } else { $retval .= getType($arg); } diff --git a/templates/list/item.phtml b/templates/list/item.phtml index 6cdfabb27a..099a211d86 100644 --- a/templates/list/item.phtml +++ b/templates/list/item.phtml @@ -32,10 +32,10 @@ ?>> - + - \ No newline at end of file +