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



commit 4766f6698f1878059b4508dcb75ab9a6a223cf1b
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 |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/src/ephy-session.c b/src/ephy-session.c
index ab0b9d9..d4621db 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -795,6 +795,33 @@ save_session_in_thread_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,
@@ -807,6 +834,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]