[epiphany] Match extension of view source temp file with original file



commit d6e428e8efcafd223875c5eb365176ba14b8ebda
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Wed Jan 2 13:14:16 2019 +0100

    Match extension of view source temp file with original file
    
    "Save Page As" option now uses mhtml for saving an entire web page in non view source mode
    and original file extensions for individual files in view source mode.
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/98

 src/window-commands.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/window-commands.c b/src/window-commands.c
index 81f5ea506..3cc16858f 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1418,25 +1418,31 @@ get_suggested_filename (EphyEmbed *embed)
   const char *mimetype;
   WebKitURIResponse *response;
   WebKitWebResource *web_resource;
+  SoupURI *soup_uri;
 
   view = ephy_embed_get_web_view (embed);
   web_resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (view));
   response = webkit_web_resource_get_response (web_resource);
   mimetype = webkit_uri_response_get_mime_type (response);
+  soup_uri = soup_uri_new (webkit_web_resource_get_uri (web_resource));
 
-  if ((g_ascii_strncasecmp (mimetype, "text/html", 9)) == 0) {
+  if (g_ascii_strncasecmp (mimetype, "text/html", 9) == 0 && g_strcmp0 (soup_uri_get_scheme (soup_uri), 
EPHY_VIEW_SOURCE_SCHEME) != 0) {
     /* Web Title will be used as suggested filename */
     suggested_filename = g_strconcat (ephy_embed_get_title (embed), ".mhtml", NULL);
   } else {
     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));
       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);
+
+      if (!strlen (suggested_filename)) {
+        g_free (suggested_filename);
+        suggested_filename = g_strdup ("index.html");
+      }
     }
   }
 
+  soup_uri_free (soup_uri);
   return suggested_filename;
 }
 


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