diff options
author | Michael Catanzaro <mcatanzaro@igalia.com> | 2017-12-14 11:05:33 -0600 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@igalia.com> | 2017-12-14 11:07:41 -0600 |
commit | 07ecaf9e9ed75b5f5898969bad9dd9192179b1ff (patch) | |
tree | d988f2d43956c607e6ac3131c49783cc75c8ca93 | |
parent | 15e32abc299705ee684ef1d02c23c38085cd89f4 (diff) | |
download | epiphany-07ecaf9e9ed75b5f5898969bad9dd9192179b1ff.tar.gz |
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.
-rw-r--r-- | src/ephy-session.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/ephy-session.c b/src/ephy-session.c index 72a3620e6..53e9dafb3 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; + } } } |