From a56ccd98d185a6d6e1d428c6c47f29d25b7e3916 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 18 Oct 2002 13:32:20 +0000 Subject: [PATCH] r1996: Cope slightly better with invalid filenames in various places (reported by Marcin Juszkiewicz and Andras Mohari). --- ROX-Filer/Help/Changes | 2 ++ ROX-Filer/src/abox.c | 8 +++++++- ROX-Filer/src/filer.c | 8 ++++++++ ROX-Filer/src/infobox.c | 14 ++++++++++++-- ROX-Filer/src/menu.c | 7 +++++-- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 6c827b88..1ba2a8e8 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -4,6 +4,8 @@ 18-Oct-2002 ~~~~~~~~~~~ +Cope slightly better with invalid filenames in various places (reported by +Marcin Juszkiewicz and Andras Mohari). Bugfix: When installing the binary release, don't warn the user that the source is missing (reported by John Pettigrew). diff --git a/ROX-Filer/src/abox.c b/ROX-Filer/src/abox.c index 53dd59e0..8ee0514c 100644 --- a/ROX-Filer/src/abox.c +++ b/ROX-Filer/src/abox.c @@ -255,16 +255,22 @@ void abox_log(ABox *abox, const gchar *message, const gchar *style) GtkTextIter end; GtkTextBuffer *text_buffer; GtkTextView *log = GTK_TEXT_VIEW(abox->log); + gchar *u8 = NULL; + + if (!g_utf8_validate(message, -1, NULL)) + u8 = to_utf8(message); text_buffer = gtk_text_view_get_buffer(log); gtk_text_buffer_get_end_iter(text_buffer, &end); gtk_text_buffer_insert_with_tags_by_name(text_buffer, - &end, message, -1, style, NULL); + &end, u8 ? u8 : message, -1, style, NULL); gtk_text_view_scroll_to_mark( log, gtk_text_buffer_get_mark(text_buffer, "insert"), 0.0, FALSE, 0, 0); + + g_free(u8); } static void abox_finalise(GObject *object) diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index 09b6b631..7cc83a6b 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -1486,7 +1486,15 @@ void filer_set_title(FilerWindow *filer_window) if (!title) title = g_strconcat(filer_window->sym_path, flags, NULL); + if (!g_utf8_validate(title, -1, NULL)) + { + char *tmp = title; + title = to_utf8(tmp); + g_free(tmp); + } + gtk_window_set_title(GTK_WINDOW(filer_window->window), title); + g_free(title); if (flags[0] != '\0') diff --git a/ROX-Filer/src/infobox.c b/ROX-Filer/src/infobox.c index a34f774d..e7547348 100644 --- a/ROX-Filer/src/infobox.c +++ b/ROX-Filer/src/infobox.c @@ -108,7 +108,9 @@ void infobox_new(const gchar *pathname) path = g_strdup(pathname); /* Gets attached to window & freed later */ - window = gtk_dialog_new_with_buttons(path, + window = gtk_dialog_new_with_buttons( + g_utf8_validate(path, -1, NULL) ? path + : _("(bad utf-8)"), NULL, GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CANCEL, GTK_RESPONSE_DELETE_EVENT, GTK_STOCK_REFRESH, GTK_RESPONSE_APPLY, @@ -313,7 +315,15 @@ static GtkWidget *make_details(guchar *path, DirItem *item) make_list(&store, &view); - add_row(store, _("Name:"), item->leafname); + if (g_utf8_validate(path, -1, NULL)) + add_row(store, _("Name:"), item->leafname); + else + { + gchar *u8; + u8 = to_utf8(path); + add_row(store, _("Name:"), u8); + g_free(u8); + } if (lstat(path, &info)) { diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c index 94564c38..5aa6ad7f 100644 --- a/ROX-Filer/src/menu.c +++ b/ROX-Filer/src/menu.c @@ -759,8 +759,11 @@ void show_filer_menu(FilerWindow *filer_window, GdkEvent *event, ViewIter *iter) shade_file_menu_items(FALSE); file_item = filer_selected_item(filer_window); g_string_sprintf(buffer, "%s '%s'", - basetype_name(file_item), - file_item->leafname); + basetype_name(file_item), + g_utf8_validate(file_item->leafname, + -1, NULL) + ? file_item->leafname + : _("(bad utf-8)")); if (!can_set_run_action(file_item)) menu_set_items_shaded(filer_file_menu, TRUE, 6, 1); -- 2.11.4.GIT