From: Christian Dywan Date: Sun, 9 Sep 2012 19:11:13 +0000 (+0200) Subject: Proper extension fallback for temporary files X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33efb946660d5b51fca214f6c0854c9fde3c3095;p=midori Proper extension fallback for temporary files --- diff --git a/midori/midori-download.vala b/midori/midori-download.vala index ce9003c3..cd294fbd 100644 --- a/midori/midori-download.vala +++ b/midori/midori-download.vala @@ -223,8 +223,8 @@ namespace Midori { /* Try to provide a good default filename, UTF-8 encoded */ string filename = clean_filename (Soup.URI.decode (uri)); /* Take the rest of the URI if needed */ - if (filename.has_suffix ("/")) - return filename + fallback_extension (null, mime_type); + if (filename.has_suffix ("/") || uri.index_of_char ('.') == -1) + return Path.build_filename (filename, fallback_extension (null, mime_type)); return filename; } diff --git a/midori/midori-view.c b/midori/midori-view.c index 808d34c2..22e1637c 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -5470,7 +5470,7 @@ midori_view_save_source (MidoriView* view, { gchar* extension = midori_download_get_extension_for_uri (uri, NULL); unique_filename = g_strdup_printf ("%s/%uXXXXXX%s", midori_paths_get_tmp_dir (), - g_str_hash (uri), midori_download_fallback_extension (view->mime_type, extension)); + g_str_hash (uri), midori_download_fallback_extension (extension, view->mime_type)); g_free (extension); katze_mkdir_with_parents (midori_paths_get_tmp_dir (), 0700); fd = g_mkstemp (unique_filename);