[epiphany] Disable libhttpseverywhere use by default for now



commit 12be12ac483001984c1b3b1b17a1b31b5b6f59be
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Dec 3 16:27:28 2016 -0600

    Disable libhttpseverywhere use by default for now
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775575

 configure.ac                             |   13 ++++++++++++-
 embed/ephy-embed-shell.c                 |   11 ++++++++++-
 embed/web-extension/ephy-uri-tester.c    |   27 +++++++++++++++++++++++++--
 embed/web-extension/ephy-web-extension.c |    4 ++++
 4 files changed, 51 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e3446dd..6024b78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -108,7 +108,6 @@ PKG_CHECK_MODULES([GNOME_DESKTOP], [gnome-desktop-3.0 >= 2.91.2])
 PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_REQUIRED])
 PKG_CHECK_MODULES([GTK_UNIX_PRINT], [gtk+-unix-print-3.0 >= $GTK_REQUIRED])
 PKG_CHECK_MODULES([HOGWEED], [hogweed >= 3.2])
-PKG_CHECK_MODULES([HTTPSEVERYWHERE], [httpseverywhere-0.2 >= 0.2.2])
 PKG_CHECK_MODULES([JSON_GLIB], [json-glib-1.0 >= 1.2.0])
 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify >= 0.5.1])
 PKG_CHECK_MODULES([LIBSECRET], [libsecret-1 >= 0.14])
@@ -120,6 +119,17 @@ PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.0])
 PKG_CHECK_MODULES([WEBKIT2GTK], [webkit2gtk-4.0 >= $WEBKITGTK_REQUIRED])
 PKG_CHECK_MODULES([WEBKIT2GTK_WEB_EXTENSION], [webkit2gtk-web-extension-4.0 >= $WEBKITGTK_REQUIRED])
 
+# libhttpseverywhere is disabled by default for now. See tracker bug #775575.
+AC_ARG_WITH([libhttpseverywhere],
+       [AS_HELP_STRING([--with-libhttpseverywhere], [Enable experimental HTTPS Everywhere support])],
+       [with_libhttpseverywhere=yes],
+       [with_libhttpseverywhere=no]
+)
+AS_IF([test "x$with_libhttpseverywhere" = "xyes"],
+       [PKG_CHECK_MODULES([HTTPSEVERYWHERE], [httpseverywhere-0.2 >= 0.2.2])
+               AC_DEFINE([HAVE_LIBHTTPSEVERYWHERE], [1], [Define if libhttpseverywhere is available])]
+)
+
 # ******************
 # Portability checks
 # ******************
@@ -220,4 +230,5 @@ Epiphany was configured with the following options:
        Extra debugging support    : $enable_debug
        Build tests                : $enable_tests
        Code coverage              : $enable_code_coverage
+       HTTPS Everywhere (unstable): $with_libhttpseverywhere
 "
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index db3aa3c..10d74fa 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -41,9 +41,12 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <httpseverywhere.h>
 #include <stdlib.h>
 
+#ifdef HAVE_LIBHTTPSEVERYWHERE
+#include <httpseverywhere.h>
+#endif
+
 #define PAGE_SETUP_FILENAME "page-setup-gtk.ini"
 #define PRINT_SETTINGS_FILENAME "print-settings.ini"
 #define OVERVIEW_RELOAD_DELAY 500
@@ -585,6 +588,7 @@ ftp_request_cb (WebKitURISchemeRequest *request)
   g_object_unref (app_info);
 }
 
+#ifdef HAVE_LIBHTTPSEVERYWHERE
 static void
 https_everywhere_update_cb (HTTPSEverywhereUpdater *updater,
                             GAsyncResult           *result)
@@ -602,6 +606,7 @@ https_everywhere_update_cb (HTTPSEverywhereUpdater *updater,
     g_warning ("Failed to update HTTPS Everywhere rulesets: %s", error->message);
   g_error_free (error);
 }
+#endif
 
 static const char *
 ephy_embed_shell_ensure_adblock_data_dir (EphyEmbedShell *shell)
@@ -764,12 +769,15 @@ ephy_embed_shell_update_uri_tester (EphyEmbedShell *shell)
 
   if (priv->mode != EPHY_EMBED_SHELL_MODE_TEST &&
       priv->mode != EPHY_EMBED_SHELL_MODE_SEARCH_PROVIDER) {
+#ifdef HAVE_LIBHTTPSEVERYWHERE
     HTTPSEverywhereContext *context;
     HTTPSEverywhereUpdater *updater;
+#endif
 
     if (!priv->uri_tester_update_cancellable)
       priv->uri_tester_update_cancellable = g_cancellable_new ();
 
+#ifdef HAVE_LIBHTTPSEVERYWHERE
     /* We might want to be smarter about this in the future. For now,
      * trigger an update of the rulesets once each time Epiphany is started. */
     context = https_everywhere_context_new ();
@@ -780,6 +788,7 @@ ephy_embed_shell_update_uri_tester (EphyEmbedShell *shell)
                                      NULL);
     g_object_unref (context);
     g_object_unref (updater);
+#endif
   }
 }
 
diff --git a/embed/web-extension/ephy-uri-tester.c b/embed/web-extension/ephy-uri-tester.c
index 43fd3c3..1b25768 100644
--- a/embed/web-extension/ephy-uri-tester.c
+++ b/embed/web-extension/ephy-uri-tester.c
@@ -32,10 +32,13 @@
 
 #include <gio/gio.h>
 #include <glib/gstdio.h>
-#include <httpseverywhere.h>
 #include <libsoup/soup.h>
 #include <string.h>
 
+#ifdef HAVE_LIBHTTPSEVERYWHERE
+#include <httpseverywhere.h>
+#endif
+
 #define SIGNATURE_SIZE 8
 
 struct _EphyUriTester {
@@ -63,9 +66,11 @@ struct _EphyUriTester {
 
   GMainLoop *load_loop;
   gboolean adblock_loaded;
+#ifdef HAVE_LIBHTTPSEVERYWHERE
   gboolean https_everywhere_loaded;
 
   HTTPSEverywhereContext *https_everywhere_context;
+#endif
 };
 
 enum {
@@ -505,10 +510,15 @@ static void
 ephy_uri_tester_adblock_loaded (EphyUriTester *tester)
 {
   tester->adblock_loaded = TRUE;
+#ifdef HAVE_LIBHTTPSEVERYWHERE
   if (tester->https_everywhere_loaded)
     g_main_loop_quit (tester->load_loop);
+#else
+  g_main_loop_quit (tester->load_loop);
+#endif
 }
 
+#ifdef HAVE_LIBHTTPSEVERYWHERE
 static void
 ephy_uri_tester_https_everywhere_loaded (EphyUriTester *tester)
 {
@@ -516,6 +526,7 @@ ephy_uri_tester_https_everywhere_loaded (EphyUriTester *tester)
   if (tester->adblock_loaded)
     g_main_loop_quit (tester->load_loop);
 }
+#endif
 
 static void
 file_parse_cb (GDataInputStream *stream, GAsyncResult *result, EphyUriTester *tester)
@@ -594,12 +605,15 @@ ephy_uri_tester_rewrite_uri (EphyUriTester    *tester,
     return NULL;
   }
 
+#ifdef HAVE_LIBHTTPSEVERYWHERE
   if ((flags & EPHY_URI_TEST_HTTPS_EVERYWHERE) && https_everywhere_context_get_initialized 
(tester->https_everywhere_context))
     return https_everywhere_context_rewrite (tester->https_everywhere_context, request_uri);
+#endif
 
   return g_strdup (request_uri);
 }
 
+#ifdef HAVE_LIBHTTPSEVERYWHERE
 static void
 https_everywhere_context_init_cb (HTTPSEverywhereContext *context,
                                   GAsyncResult           *res,
@@ -616,6 +630,7 @@ https_everywhere_context_init_cb (HTTPSEverywhereContext *context,
 
   ephy_uri_tester_https_everywhere_loaded (tester);
 }
+#endif
 
 static void
 adblock_file_monitor_changed (GFileMonitor     *monitor,
@@ -645,10 +660,12 @@ ephy_uri_tester_load_sync (GTask         *task,
   tester->load_loop = g_main_loop_new (context, FALSE);
   g_main_context_push_thread_default (context);
 
+#ifdef HAVE_LIBHTTPSEVERYWHERE
   tester->https_everywhere_context = https_everywhere_context_new ();
   https_everywhere_context_init (tester->https_everywhere_context, NULL,
                                  (GAsyncReadyCallback)https_everywhere_context_init_cb,
                                  tester);
+#endif
 
   filter_file = ephy_uri_tester_get_adblock_filer_file (tester->adblock_data_dir);
   if (!g_file_query_exists (filter_file, NULL)) {
@@ -776,7 +793,9 @@ ephy_uri_tester_finalize (GObject *object)
   g_regex_unref (tester->regex_subdocument);
   g_regex_unref (tester->regex_frame_add);
 
+#ifdef HAVE_LIBHTTPSEVERYWHERE
   g_clear_object (&tester->https_everywhere_context);
+#endif
 
   G_OBJECT_CLASS (ephy_uri_tester_parent_class)->finalize (object);
 }
@@ -812,7 +831,11 @@ ephy_uri_tester_load (EphyUriTester *tester)
 
   g_return_if_fail (EPHY_IS_URI_TESTER (tester));
 
-  if (tester->adblock_loaded && tester->https_everywhere_loaded)
+  if (tester->adblock_loaded
+#ifdef HAVE_LIBHTTPSEVERYWHERE
+      && tester->https_everywhere_loaded
+#endif
+     )
     return;
 
   task = g_task_new (tester, NULL, NULL, NULL);
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index d95f4fa..71f2c82 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -111,6 +111,7 @@ static gboolean
 should_use_https_everywhere (const char *request_uri,
                              const char *redirected_uri)
 {
+#ifdef HAVE_LIBHTTPSEVERYWHERE
   SoupURI *request_soup_uri;
   SoupURI *redirected_soup_uri;
   gboolean result = TRUE;
@@ -142,6 +143,9 @@ should_use_https_everywhere (const char *request_uri,
   soup_uri_free (redirected_soup_uri);
 
   return result;
+#else
+  return FALSE;
+#endif
 }
 
 static gboolean


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