[epiphany] session: Rework the safety check
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] session: Rework the safety check
- Date: Thu, 14 Dec 2017 17:07:52 +0000 (UTC)
commit 07ecaf9e9ed75b5f5898969bad9dd9192179b1ff
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Thu Dec 14 11:05:33 2017 -0600
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.
src/ephy-session.c | 40 ++++++++++++++++++++++++----------------
1 files changed, 24 insertions(+), 16 deletions(-)
---
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 72a3620..53e9daf 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;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]