Commit 8e82c479 authored by Adrián Pérez de Castro's avatar Adrián Pérez de Castro Committed by Michael Catanzaro

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
parent 24ca3fb8
......@@ -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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment