Files
FreshRSS/lib/Minz/Helper.php
Alexandre Alapetite a8a544a2a2 Fix search encoding and quoting (#8311)
Revised the encoding approach for searches: the HTML encoding is done just before its use for DB search.
Fix also some cases with wrong quoting.
Fix https://github.com/FreshRSS/FreshRSS/pull/8306#issuecomment-3643865439
Follow-up of https://github.com/FreshRSS/FreshRSS/pull/8293
2025-12-13 11:31:34 +01:00

34 lines
792 B
PHP

<?php
declare(strict_types=1);
/**
* MINZ - Copyright 2011 Marien Fressinaud
* Sous licence AGPL3 <http://www.gnu.org/licenses/>
*/
/**
* The Minz_Helper class contains some misc. help functions
*/
final class Minz_Helper {
/**
* Wrapper for htmlspecialchars.
* Force UTF-8 value and can be used on array too.
*
* @phpstan-template T of mixed
* @phpstan-param T $var
* @phpstan-return T
*/
public static function htmlspecialchars_utf8(mixed $var, int $flags = ENT_COMPAT): mixed {
if (is_array($var)) {
// @phpstan-ignore return.type
return array_map(fn($v) => self::htmlspecialchars_utf8($v, $flags), $var);
} elseif (is_string($var)) {
// @phpstan-ignore return.type
return htmlspecialchars($var, $flags, 'UTF-8');
} else {
return $var;
}
}
}