[epiphany/gnome-3-22] session: Add a safety check



commit 9b9acad568fad0ba33c6372293bb120ead4abd11
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 ce3438a..afb2a49 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -811,6 +811,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,
@@ -823,6 +845,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) goto out;


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