From 57eac14d82b6cb7acfa043546dedb63c3dc21f74 Mon Sep 17 00:00:00 2001 From: Robert Fewell <14uBobIT@gmail.com> Date: Tue, 9 Apr 2019 17:23:20 +0100 Subject: [PATCH] Bug 797183 - association head path with spaces displayed wrong The Transaction Association path head was being displayed with '%20' as the space as it was not being unescaped. Fixed by unescaping and also noticed that the error message string were wrong also. --- gnucash/gnome-utils/gnc-gnome-utils.c | 24 ++++++++++++++++++++---- gnucash/gnome/dialog-trans-assoc.c | 4 +++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/gnucash/gnome-utils/gnc-gnome-utils.c b/gnucash/gnome-utils/gnc-gnome-utils.c index 008c9f62b9..66900501ed 100644 --- a/gnucash/gnome-utils/gnc-gnome-utils.c +++ b/gnucash/gnome-utils/gnc-gnome-utils.c @@ -483,14 +483,15 @@ void gnc_launch_assoc (const char *uri) { wchar_t *winuri = NULL; + gchar *filename = NULL; /* ShellExecuteW open doesn't decode http escapes if it's passed a * file URI so we have to do it. */ if (gnc_uri_is_file_uri (uri)) { gchar *uri_ue = g_uri_unescape_string (uri, NULL); - gchar *filename = gnc_uri_get_path (uri_ue); + filename = gnc_uri_get_path (uri_ue); + filename = g_strdelimit (filename, "/", '\\'); // needed for unc paths winuri = (wchar_t *)g_utf8_to_utf16(filename, -1, NULL, NULL, NULL); - g_free (filename); g_free (uri_ue); } else @@ -505,10 +506,11 @@ gnc_launch_assoc (const char *uri) { const gchar *message = _("GnuCash could not find the associated file"); - gnc_error_dialog(NULL, "%s: %s", message, uri); + gnc_error_dialog(NULL, "%s:\n%s", message, filename); } g_free (wincmd); g_free (winuri); + g_free (filename); } } @@ -533,9 +535,23 @@ gnc_launch_assoc (const char *uri) g_assert(error != NULL); { + gchar *error_uri = NULL; const gchar *message = _("GnuCash could not open the associated URI:"); - gnc_error_dialog(NULL, "%s\n%s", message, uri); + + if (gnc_uri_is_file_uri (uri)) + { + gchar *uri_ue = g_uri_unescape_string (uri, NULL); + gchar *filename = gnc_uri_get_path (uri_ue); + error_uri = g_strdup (filename); + g_free (uri_ue); + g_free (filename); + } + else + error_uri = g_strdup (uri); + + gnc_error_dialog(NULL, "%s\n%s", message, error_uri); + g_free (error_uri); } PERR ("%s", error->message); g_error_free(error); diff --git a/gnucash/gnome/dialog-trans-assoc.c b/gnucash/gnome/dialog-trans-assoc.c index 8be4703175..5db3fc239b 100644 --- a/gnucash/gnome/dialog-trans-assoc.c +++ b/gnucash/gnome/dialog-trans-assoc.c @@ -486,7 +486,8 @@ gnc_assoc_dialog_create (GtkWindow *parent, AssocDialog *assoc_dialog) if (assoc_dialog->path_head && g_strcmp0 (assoc_dialog->path_head, "") != 0) // not default entry { - gchar *path_head_str = gnc_uri_get_path (assoc_dialog->path_head); + gchar *path_head_ue_str = g_uri_unescape_string (assoc_dialog->path_head, NULL); + gchar *path_head_str = gnc_uri_get_path (path_head_ue_str); gchar *path_head_label; // test for current folder being present @@ -499,6 +500,7 @@ gnc_assoc_dialog_create (GtkWindow *parent, AssocDialog *assoc_dialog) gtk_label_set_text (GTK_LABEL(path_head), path_head_label); g_free (path_head_label); g_free (path_head_str); + g_free (path_head_ue_str); } else {