[epiphany/gnome-3-24] Decode last component of URIs to determine file names for saving



commit 8e82c479cc1fbe570f7d2b68fb2eb862c645263a
Author: Adrian Perez de Castro <aperez igalia com>
Date:   Wed Mar 15 14:31:39 2017 +0200

    Decode last component of URIs to determine file names for saving
    
    In the logic to determine which filename to use when saving a non-HTML
    resource the last component of the URI was being used as-is, which could
    include percent-encoded characters. Calling soup_uri_decode() before
    using the value ensures that we present readable file names to the user.
    
    Also, this stops using g_file_get_basename() to extract the last
    component of an URI because it would horribly break on platforms which
    do not use a slash (“/”) as path separator.
    
    This fixes bug #780086

 src/window-commands.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/src/window-commands.c b/src/window-commands.c
index cd5fc70..d48df1b 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1435,7 +1435,8 @@ get_suggested_filename (EphyEmbed *embed)
     suggested_filename = g_strdup (webkit_uri_response_get_suggested_filename (response));
     if (!suggested_filename) {
       SoupURI *soup_uri = soup_uri_new (webkit_web_resource_get_uri (web_resource));
-      suggested_filename = g_path_get_basename (soup_uri->path);
+      char *last_slash = strrchr (soup_uri->path, '/');
+      suggested_filename = soup_uri_decode (last_slash ? (last_slash + 1) : soup_uri->path);
       soup_uri_free (soup_uri);
     }
   }


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