[epiphany/gnome-3-26] session: Rework the safety check



commit 370b87f27fa9ad8be201d33f4eb6cf5ec39e3f56
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Thu Dec 14 11:05:33 2017 -0600

    session: Rework the safety check
    
    Tanty and I both lost our Epiphany sessions yesterday... we need to
    tighten up our URI sanity check. http:/// is a valid SoupURI, but it
    should never be saved in the session.

 src/ephy-session.c |   40 ++++++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 16 deletions(-)
---
diff --git a/src/ephy-session.c b/src/ephy-session.c
index b07346f..64f135a 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -822,22 +822,30 @@ save_session_in_thread_finished_cb (GObject      *source_object,
 static gboolean
 session_seems_sane (GList *windows)
 {
-  GList *w;
-  GList *t;
+  for (GList *w = windows; w != NULL; w = w->next) {
+    for (GList *t = ((SessionWindow *)w->data)->tabs; t != NULL; t = t->next) {
+      const char *url = ((SessionTab *)t->data)->url;
+      SoupURI *uri;
+      gboolean sane = FALSE;
+
+      /* Blank URLs can occur in some situations. Just ignore these, as they
+       * are harmless and not an indicator of a corrupted session. */
+      if (strcmp (url, "") == 0)
+        continue;
+
+      uri = soup_uri_new (url);
+      if (uri) {
+        if (uri->host != NULL ||
+            uri->scheme == SOUP_URI_SCHEME_DATA ||
+            uri->scheme == SOUP_URI_SCHEME_FILE)
+          sane = TRUE;
+        soup_uri_free (uri);
+      }
 
-  for (w = windows; w != NULL; w = w->next) {
-    for (t = ((SessionWindow *)w->data)->tabs; t != NULL; t = t->next) {
-       const char *url = ((SessionTab *)t->data)->url;
-       SoupURI *uri = soup_uri_new (url);
-       if (uri) {
-         soup_uri_free (uri);
-       }
-       /* Blank URLs can occur in some situations. Don't save them, but also
-        * do not torpedo the entire session as it's not a bug. */
-       else if (strcmp (url, "") != 0) {
-         g_critical ("Refusing to save session due to invalid URL %s", url);
-         return FALSE;
-       }
+      if (!sane) {
+        g_critical ("Refusing to save session due to invalid URL %s", url);
+        return FALSE;
+      }
     }
   }
 


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