Requesting hard code freeze break for gnome-utils

hi everyone;

there's a bug opened for the screenshot utility in gnome-utils which
might lead to critical data loss:

it's triggered by an error in the filename conversion error from UTF-8
in non UTF-8 locales; it happens when taking a screenshot of a window
with a title in UTF-8 and trying to save it in a UTF-8 encoded file
system; as the reporter said, if you aren't extra careful in reading the
error message, it might destroy data by replacing the default folder
with an image.

the patch attached to this mail at least avoids data loss - doesn't
affect any string and/or visible UI, so I don't think it needs an
approval from either the i18n or the doc teams, but if needed I'll
forward this mail to them too.

this is a weird corner case, though, and the patch might just wait for
the 2.18.1 release.


Emmanuele Bassi,  E: ebassi gmail com
Index: ChangeLog
--- ChangeLog	(revision 7452)
+++ ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2007-03-10  Emmanuele Bassi  <ebassi gnome org>
+	* screenshot-dialog.c: Warn (in console) if g_filename_from_utf8()
+	fails to convert the screenshot file name in case we are not in
+	a utf8 locale, and fall back to the default screenshot file name,
+	to avoid eating the user's folders. (#411050, thanks to
+	Pascal Terjan for his detective work)
 2007-03-04  Emmanuele Bassi  <ebassi gnome org>
 	* gnome-screenshot.c: Add call to gettext() in order to
Index: screenshot-dialog.c
--- screenshot-dialog.c	(revision 7452)
+++ screenshot-dialog.c	(working copy)
@@ -312,13 +312,26 @@ screenshot_dialog_get_uri (ScreenshotDia
   gchar *folder;
   const gchar *file_name;
   gchar *uri, *file, *tmp;
+  GError *error;
   folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog->save_widget));
   file_name = gtk_entry_get_text (GTK_ENTRY (dialog->filename_entry));
-  tmp = g_filename_from_utf8 (file_name, -1, NULL, NULL, NULL);
+  error = NULL;
+  tmp = g_filename_from_utf8 (file_name, -1, NULL, NULL, &error);
+  if (error)
+    {
+      g_warning ("Unable to convert `%s' to valid UTF-8: %s\n"
+                 "Falling back to default file.",
+                 file_name,
+                 error->message);
+      g_error_free (error);
+      tmp = g_strdup (_("Screenshot.png"));
+    }
   file = gnome_vfs_escape_host_and_path_string (tmp);
   uri = g_build_filename (folder, file, NULL);
   g_free (folder);
   g_free (tmp);
   g_free (file);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]