From 6e2f2f1c1e98ecd86aa89c6547beb742d7385d18 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Thu, 11 May 2023 13:02:04 +0200 Subject: A few additional PHPStan rules (#5388) A subset of https://github.com/phpstan/phpstan-strict-rules --- lib/lib_rss.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/lib_rss.php') diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 9c9d44a4c..1ae99e6a1 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -224,7 +224,7 @@ function html_only_entity_decode(?string $text): string { function sensitive_log($log) { if (is_array($log)) { foreach ($log as $k => $v) { - if (in_array($k, ['api_key', 'Passwd', 'T'])) { + if (in_array($k, ['api_key', 'Passwd', 'T'], true)) { $log[$k] = '██'; } elseif (is_array($v) || is_string($v)) { $log[$k] = sensitive_log($v); @@ -331,7 +331,7 @@ function customSimplePie(array $attributes = array()): SimplePie { /** @param string $data */ function sanitizeHTML(string $data, string $base = '', ?int $maxLength = null): string { - if (!is_string($data) || ($maxLength !== null && $maxLength <= 0)) { + if ($data === '' || ($maxLength !== null && $maxLength <= 0)) { return ''; } if ($maxLength !== null) { @@ -851,8 +851,9 @@ function errorMessageInfo(string $errorTitle, string $error = ''): string { $message = ''; $details = ''; - // Prevent empty tags by checking if error isn not empty first - if ($error) { + $error = trim($error); + // Prevent empty tags by checking if error is not empty first + if ($error !== '') { $error = htmlspecialchars($error, ENT_NOQUOTES, 'UTF-8') . "\n"; // First line is the main message, other lines are the details -- cgit v1.2.3