diff options
| author | 2025-05-07 19:55:28 +0200 | |
|---|---|---|
| committer | 2025-05-07 19:55:28 +0200 | |
| commit | 25f57beb90e1424a4fb885d335bc9ad1fa8dce69 (patch) | |
| tree | a2d1456181e2a80b1a7a31bc3c92cebbb054425f | |
| parent | f2a7af03e820a01188475cceb654dac2074e4505 (diff) | |
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
| -rw-r--r-- | app/Models/Themes.php | 9 |
1 files changed, 6 insertions, 3 deletions
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<string>,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; } } |
