From fb11a03687d75a3566b19aafad16fd02d3f43f5d Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Sat, 12 Nov 2011 16:18:28 +0300 Subject: [PATCH] Escape out the RC file delimiter ] from filenames when reading/writing to it. Fixes bug 2975 --- src/xfdesktop-file-icon-manager.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/xfdesktop-file-icon-manager.c b/src/xfdesktop-file-icon-manager.c index d3ca2eb..a516281 100644 --- a/src/xfdesktop-file-icon-manager.c +++ b/src/xfdesktop-file-icon-manager.c @@ -1704,12 +1704,16 @@ file_icon_hash_write_icons(gpointer key, XfceRc *rcfile = data; XfdesktopIcon *icon = value; guint16 row, col; + gchar *escaped_str = g_strdup(xfdesktop_icon_peek_label(icon)); if(xfdesktop_icon_get_position(icon, &row, &col)) { - xfce_rc_set_group(rcfile, xfdesktop_icon_peek_label(icon)); + /* ']' is the RC file's delimiter so we escape it with a non-printable character. Fixes bug 2975 */ + escaped_str = g_strdelimit(escaped_str, "]", '\a'); + xfce_rc_set_group(rcfile, escaped_str); xfce_rc_write_int_entry(rcfile, "row", row); xfce_rc_write_int_entry(rcfile, "col", col); } + g_free(escaped_str); } static gboolean @@ -1788,13 +1792,16 @@ xfdesktop_file_icon_manager_get_cached_icon_position(XfdesktopFileIconManager *f gchar relpath[PATH_MAX]; XfceRc *rcfile; gboolean ret = FALSE; + gchar *escaped_str = g_strdup(name); g_snprintf(relpath, PATH_MAX, "xfce4/desktop/icons.screen%d.rc", gdk_screen_get_number(fmanager->priv->gscreen)); rcfile = xfce_rc_config_open(XFCE_RESOURCE_CONFIG, relpath, TRUE); if(rcfile) { - if(xfce_rc_has_group(rcfile, name)) { - xfce_rc_set_group(rcfile, name); + /* ']' is the RC file's delimiter so we escape it with a non-printable character. Fixes bug 2975 */ + escaped_str = g_strdelimit(escaped_str, "]", '\a'); + if(xfce_rc_has_group(rcfile, escaped_str)) { + xfce_rc_set_group(rcfile, escaped_str); *row = xfce_rc_read_int_entry(rcfile, "row", -1); *col = xfce_rc_read_int_entry(rcfile, "col", -1); if(*row >= 0 && *col >= 0) @@ -1803,6 +1810,7 @@ xfdesktop_file_icon_manager_get_cached_icon_position(XfdesktopFileIconManager *f xfce_rc_close(rcfile); } + g_free(escaped_str); return ret; } -- 1.7.5.4