Proper extension fallback for temporary files

This commit is contained in:
Christian Dywan 2012-09-09 21:11:13 +02:00
parent dd90c2b65b
commit 33efb94666
2 changed files with 3 additions and 3 deletions

View file

@ -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;
}

View file

@ -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);