From: Alexander Ebert Date: Fri, 27 Jun 2014 23:17:27 +0000 (+0200) Subject: Prevent non-critical exceptions in the ACP to include a stacktrace X-Git-Tag: 2.1.0_Alpha_1~659 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1037d65fd61e4ef37aa19d016f659397027aea6b;p=GitHub%2FWoltLab%2FWCF.git Prevent non-critical exceptions in the ACP to include a stacktrace For example throwing a PermissionDeniedException would cause a stacktrace to be printed, even though it is not meant to be an error in terms of a critical exception. --- diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 28cd574b1c..7c0008d30d 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -676,11 +676,12 @@ class WCF { /** * Returns true if the debug mode is enabled, otherwise false. * + * @param boolean $ignoreACP * @return boolean */ - public static function debugModeIsEnabled() { + public static function debugModeIsEnabled($ignoreACP = false) { // ACP override - if (self::$overrideDebugMode) { + if (!$ignoreACP && self::$overrideDebugMode) { return true; } else if (defined('ENABLE_DEBUG_MODE') && ENABLE_DEBUG_MODE) { diff --git a/wcfsetup/install/files/lib/system/exception/AJAXException.class.php b/wcfsetup/install/files/lib/system/exception/AJAXException.class.php index 854b41f905..6d9c2762a2 100644 --- a/wcfsetup/install/files/lib/system/exception/AJAXException.class.php +++ b/wcfsetup/install/files/lib/system/exception/AJAXException.class.php @@ -69,7 +69,10 @@ class AJAXException extends LoggedException { 'returnValues' => $returnValues ); - if (WCF::debugModeIsEnabled()) { + // include a stacktrace if: + // - debug mode is enabled + // - within ACP and a SystemException was thrown + if (WCF::debugModeIsEnabled(false) || WCF::debugModeIsEnabled() && self::INTERNAL_ERROR) { $responseData['stacktrace'] = nl2br($stacktrace); }