aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_rss.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-12-16 10:48:20 +0100
committerGravatar GitHub <noreply@github.com> 2025-12-16 10:48:20 +0100
commit493bb88535cd73da59cc1a870489824d9b3bba6d (patch)
tree23dc079d351f7f6a176de780380db9f5215a9669 /lib/lib_rss.php
parent19666d70ed47df0909b501f51090632e7b2e26cc (diff)
Safer handling of DB null content (#8319)
https://github.com/FreshRSS/FreshRSS/discussions/8314#discussioncomment-15261119
Diffstat (limited to 'lib/lib_rss.php')
-rw-r--r--lib/lib_rss.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 2fca6896f..7636ee225 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -150,16 +150,16 @@ function safe_ascii(?string $text): string {
}
if (function_exists('mb_convert_encoding')) {
- function safe_utf8(string $text): string {
- return mb_convert_encoding($text, 'UTF-8', 'UTF-8') ?: '';
+ function safe_utf8(?string $text): string {
+ return $text === null ? '' : (mb_convert_encoding($text, 'UTF-8', 'UTF-8') ?: '');
}
} elseif (function_exists('iconv')) {
- function safe_utf8(string $text): string {
- return iconv('UTF-8', 'UTF-8//IGNORE', $text) ?: '';
+ function safe_utf8(?string $text): string {
+ return $text === null ? '' : (iconv('UTF-8', 'UTF-8//IGNORE', $text) ?: '');
}
} else {
- function safe_utf8(string $text): string {
- return $text;
+ function safe_utf8(?string $text): string {
+ return $text ?? '';
}
}