From 937fad41aa0abba6141754b286a43c03b1df9667 Mon Sep 17 00:00:00 2001 From: prdatur Date: Tue, 30 Mar 2021 13:54:34 +0200 Subject: [PATCH] - Enhance PrettyPageHandler to allow hiding super globals with non-string value. (non-string values will have a fixed asterisk length of 3) - Fix missing @throws annotation. - Fix typo in doc-block - Add new string/non-string behaviour to doc-block description. Fixes #690 --- src/Whoops/Handler/PrettyPageHandler.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Whoops/Handler/PrettyPageHandler.php b/src/Whoops/Handler/PrettyPageHandler.php index c26b80b..c6c8be0 100644 --- a/src/Whoops/Handler/PrettyPageHandler.php +++ b/src/Whoops/Handler/PrettyPageHandler.php @@ -175,6 +175,8 @@ class PrettyPageHandler extends Handler /** * @return int|null + * + * @throws \Exception */ public function handle() { @@ -801,9 +803,10 @@ class PrettyPageHandler extends Handler /** * Checks all values within the given superGlobal array. * - * Blacklisted values will be replaced by a equal length string cointaining - * only '*' characters. We intentionally dont rely on $GLOBALS as it - * depends on the 'auto_globals_jit' php.ini setting. + * Blacklisted values will be replaced by a equal length string containing + * only '*' characters for string values. + * Non-string values will be replaced with a fixed asterisk count. + * We intentionally dont rely on $GLOBALS as it depends on the 'auto_globals_jit' php.ini setting. * * @param array $superGlobal One of the superglobal arrays * @param string $superGlobalName The name of the superglobal array, e.g. '_GET' @@ -817,8 +820,8 @@ class PrettyPageHandler extends Handler $values = $superGlobal; foreach ($blacklisted as $key) { - if (isset($superGlobal[$key]) && is_string($superGlobal[$key])) { - $values[$key] = str_repeat('*', strlen($superGlobal[$key])); + if (isset($superGlobal[$key])) { + $values[$key] = str_repeat('*', is_string($superGlobal[$key]) ? strlen($superGlobal[$key]) : 3); } }