diff options
| author | 2019-11-11 19:48:45 +0100 | |
|---|---|---|
| committer | 2019-11-11 19:48:45 +0100 | |
| commit | bec75664293047267c8ab5dd6967d78bcdbbf8ff (patch) | |
| tree | c3974ba75d8c826cbcb13bdb57e0c8dafd2191a9 /lib | |
| parent | 6fb60d470aaa3c1e62dc1a61f786abdd6e428106 (diff) | |
Sanitize UTF-8 before commiting entries (#2649)
Fix https://github.com/FreshRSS/FreshRSS/issues/2645
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/lib_rss.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index f4b5c68e6..137c7f2d5 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -81,6 +81,14 @@ function safe_ascii($text) { return filter_var($text, FILTER_DEFAULT, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH); } +if (function_exists('mb_convert_encoding')) { + function safe_utf8($text) { return mb_convert_encoding($text, 'UTF-8', 'UTF-8'); } +} elseif (function_exists('iconv')) { + function safe_utf8($text) { return iconv('UTF-8', 'UTF-8//IGNORE', $text); } +} else { + function safe_utf8($text) { return $text; } +} + function escapeToUnicodeAlternative($text, $extended = true) { $text = htmlspecialchars_decode($text, ENT_QUOTES); |
