From 25f57beb90e1424a4fb885d335bc9ad1fa8dce69 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 7 May 2025 19:55:28 +0200 Subject: Fix encoding of themes (#7565) * Fix encoding of themes Several HTML and URL encoding issues in the case of special chars in theme directory or in metadata. Also usefull to simplify https://github.com/FreshRSS/FreshRSS/pull/7559 * Minor simplification * Stricter decoding --- app/Models/Themes.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/Models') diff --git a/app/Models/Themes.php b/app/Models/Themes.php index 2b5bff2f7..ef44b0b75 100644 --- a/app/Models/Themes.php +++ b/app/Models/Themes.php @@ -20,19 +20,21 @@ class FreshRSS_Themes extends Minz_Model { $themes_list = self::getList(); $list = []; foreach ($themes_list as $theme_dir) { - $theme = self::get_infos($theme_dir); + $theme_id = rawurlencode($theme_dir); + $theme = self::get_infos($theme_id); if (is_array($theme) && trim($theme['name']) !== '') { - $list[$theme_dir] = $theme; + $list[$theme_id] = $theme; } } return $list; } /** + * @param string $theme_id is the rawurlencode'd theme directory name * @return false|array{id:string,name:string,author:string,description:string,version:float|string,files:array,theme-color?:string|array{dark?:string,light?:string,default?:string}} */ public static function get_infos(string $theme_id): array|false { - $theme_dir = PUBLIC_PATH . self::$themesUrl . $theme_id; + $theme_dir = PUBLIC_PATH . self::$themesUrl . rawurldecode($theme_id); if (is_dir($theme_dir)) { $json_filename = $theme_dir . '/metadata.json'; if (file_exists($json_filename)) { @@ -55,6 +57,7 @@ class FreshRSS_Themes extends Minz_Model { 'default' => is_string($res['theme-color']['default'] ?? null) ? $res['theme-color']['default'] : '', ]; } + $result = Minz_Helper::htmlspecialchars_utf8($result); return $result; } } -- cgit v1.2.3