From 1c53464090946efb7bd18c80d4ea52bd77d0538c Mon Sep 17 00:00:00 2001 From: Andreas Hartmann Date: Sun, 30 May 2021 17:59:36 +0200 Subject: [PATCH] fbd-feedback-manager: Make sure theme path components are '/' separated Previously, assembly of the theme paths for custom paths (based on `XDG_DATA_DIRS`) was performed using `g_strconcat`, which produced erroneous file paths with missing path separators due to a typo in the code. Instead, make use of `g_build_filename` to assemble the theme paths from `XDG_DATA_DIRS` to look for custom themes, which automatically introduces host-specific path separators between individual path components. This introduces another temporary variable to ensure that the filename (which is itself assembled from a name and the file ending) isn't mangled by introduction of a path separator between these two "parts". --- src/fbd-feedback-manager.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fbd-feedback-manager.c b/src/fbd-feedback-manager.c index 39c27eb..c592f86 100644 --- a/src/fbd-feedback-manager.c +++ b/src/fbd-feedback-manager.c @@ -454,8 +454,12 @@ find_themefile (void) // Iterate over $XDG_DATA_DIRS for (i = 0; i < g_strv_length (xdg_data_dirs); i++) { g_autofree gchar *config_path = NULL; + g_autofree gchar *theme_file_name = NULL; - config_path = g_strconcat (xdg_data_dirs[i], "feedbackd/themes/", comp, ".json", NULL); + // We leave it to g_build_filename to add/remove erroneous path separators + theme_file_name = g_strconcat (comp, ".json", NULL); + config_path = g_build_filename (xdg_data_dirs[i], "feedbackd", "themes", + theme_file_name, NULL); g_debug ("Searching for device specific themefile in %s", config_path); // Check if file exist