[epiphany] session: Add a safety check



commit e212e2fa04f266026f63a65944a70596cf67825e
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Mon Oct 17 07:21:42 2016 -0500

    session: Add a safety check
    
    Never replace a good session file with one that's known to be broken.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768250

 src/ephy-session.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/src/ephy-session.c b/src/ephy-session.c
index fe80eb3..30eef45 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -827,6 +827,28 @@ save_session_in_thread_finished_cb (GObject      *source_object,
   g_application_release (G_APPLICATION (ephy_shell_get_default ()));
 }
 
+static gboolean
+session_seems_sane (GList *windows)
+{
+  GList *w;
+  GList *t;
+
+  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);
+       } else {
+         g_critical ("Refusing to save session due to invalid URL %s", url);
+         return FALSE;
+       }
+    }
+  }
+
+  return TRUE;
+}
+
 static void
 save_session_sync (GTask        *task,
                    gpointer      source_object,
@@ -839,6 +861,14 @@ save_session_sync (GTask        *task,
   GList *w;
   int ret = -1;
 
+  /* If any web view has an insane URL, then something has probably gone wrong
+   * inside WebKit. For instance, if the web process is nonfunctional, the UI
+   * process could have an invalid URI property. Yes, this would be a WebKit
+   * bug, but Epiphany should be robust to such issues. Do not clobber an
+   * existing good session file with our new bogus state. Bug #768250. */
+  if (!session_seems_sane (data->windows))
+    return;
+
   buffer = xmlBufferCreate ();
   writer = xmlNewTextWriterMemory (buffer, 0);
   if (writer == NULL)


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