summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@gnome.org>2016-10-17 07:21:42 -0500
committerMichael Catanzaro <mcatanzaro@gnome.org>2016-10-17 07:23:14 -0500
commit9b9acad568fad0ba33c6372293bb120ead4abd11 (patch)
tree9249015b10a5a5535ec0274c02adfc706f17f98a
parent4f5800f8ae4bf8dbf5910ff30915c0e66012c66e (diff)
downloadepiphany-9b9acad568fad0ba33c6372293bb120ead4abd11.tar.gz
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
-rw-r--r--src/ephy-session.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ephy-session.c b/src/ephy-session.c
index ce3438a48..afb2a49fd 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;