diff options
Diffstat (limited to 'modules/gallery/libraries/MY_Kohana_Exception.php')
| -rw-r--r-- | modules/gallery/libraries/MY_Kohana_Exception.php | 27 | 
1 files changed, 18 insertions, 9 deletions
| diff --git a/modules/gallery/libraries/MY_Kohana_Exception.php b/modules/gallery/libraries/MY_Kohana_Exception.php index 72cb2ac0..82899d7e 100644 --- a/modules/gallery/libraries/MY_Kohana_Exception.php +++ b/modules/gallery/libraries/MY_Kohana_Exception.php @@ -22,11 +22,15 @@ class Kohana_Exception extends Kohana_Exception_Core {     * Dump out the full stack trace as part of the text representation of the exception.     */    public static function text($e) { -    return sprintf( -      "%s [ %s ]: %s\n%s [ %s ]\n%s", -      get_class($e), $e->getCode(), strip_tags($e->getMessage()), -      $e->getFile(), $e->getLine(), -      $e->getTraceAsString()); +    if ($e instanceof Kohana_404_Exception) { +      return "File not found: " . Router::$complete_uri; +    } else { +      return sprintf( +        "%s [ %s ]: %s\n%s [ %s ]\n%s", +        get_class($e), $e->getCode(), strip_tags($e->getMessage()), +        $e->getFile(), $e->getLine(), +        $e->getTraceAsString()); +    }    }    /** @@ -41,16 +45,21 @@ class Kohana_Exception extends Kohana_Exception_Core {     * data, such as session ids and passwords / hashes.     */    public static function safe_dump($value, $key, $length=128, $max_level=5) { -    return parent::dump(self::_sanitize_for_dump($value, $key), $length, $max_level); +    return parent::dump(self::_sanitize_for_dump($value, $key, $max_level), $length, $max_level);    }    /**     * Elides sensitive data which shouldn't be echoed to the client,     * such as passwords, and other secrets.     */ -  /* Visible for testing*/ static function _sanitize_for_dump($value, $key=null) { +  /* Visible for testing*/ static function _sanitize_for_dump($value, $key=null, $max_level) {      // Better elide too much than letting something through.      // Note: unanchored match is intended. +    if (!$max_level) { +      // Too much recursion; give up.  We gave it our best shot. +      return $value; +    } +      $sensitive_info_pattern =        '/(password|pass|email|hash|private_key|session_id|session|g3sid|csrf|secret)/i';      if (preg_match($sensitive_info_pattern, $key) || @@ -63,7 +72,7 @@ class Kohana_Exception extends Kohana_Exception_Core {        } else if ($value instanceof User_Model) {          return get_class($value) . ' object for "' . $value->name . '" - details omitted for display';        } -      return self::_sanitize_for_dump((array) $value, $key); +      return self::_sanitize_for_dump((array) $value, $key, $max_level - 1);      } else if (is_array($value)) {        $result = array();        foreach ($value as $k => $v) { @@ -78,7 +87,7 @@ class Kohana_Exception extends Kohana_Exception_Core {          if (is_object($v)) {            $key_for_display .= ' (type: ' . get_class($v) . ')';          } -        $result[$key_for_display] = self::_sanitize_for_dump($v, $actual_key); +        $result[$key_for_display] = self::_sanitize_for_dump($v, $actual_key, $max_level - 1);        }      } else {        $result = $value; | 
