[epiphany] Initial libhttpseverywhere integration
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Initial libhttpseverywhere integration
- Date: Sun, 9 Oct 2016 14:55:35 +0000 (UTC)
commit a7ce46e7809fac864ee417df41f663e7ab1d046a
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Sep 18 22:10:47 2016 -0500
Initial libhttpseverywhere integration
This includes a workaround for a silly bug.
Future work would be to ignore TLS errors if for rewritten URLs. (We
should not be strict with these because there could be bugs in the HTTPS
Everywhere ruleset. We should only be strict when the site itself
redirects to HTTPS, or when the user navigates to an HTTPS page.)
configure.ac | 1 +
embed/web-extension/Makefile.am | 24 +++++++++++++-----------
embed/web-extension/ephy-web-extension.c | 19 ++++++++++++++++++-
3 files changed, 32 insertions(+), 12 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d378e57..5a71aee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -110,6 +110,7 @@ PKG_CHECK_MODULES([GNOME_DESKTOP], [gnome-desktop-3.0 >= 2.91.2])
PKG_CHECK_MODULES([GTHREAD], [gthread-2.0 >= $GLIB_REQUIRED])
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([HTTPSEVERYWHERE], [httpseverywhere-0.2 >= 0.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])
diff --git a/embed/web-extension/Makefile.am b/embed/web-extension/Makefile.am
index d0c2560..e0eaf3d 100644
--- a/embed/web-extension/Makefile.am
+++ b/embed/web-extension/Makefile.am
@@ -19,12 +19,13 @@ libephywebextension_la_SOURCES = \
ephy-web-overview-model.c
libephywebextension_la_CPPFLAGS = \
- -I$(top_srcdir)/lib \
- $(GIO_CFLAGS) \
- $(GLIB_CFLAGS) \
- $(GTK_CFLAGS) \
- $(LIBSECRET_CFLAGS) \
- $(LIBSOUP_CFLAGS) \
+ -I$(top_srcdir)/lib \
+ $(GIO_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(HTTPSEVERYWHERE_CFLAGS) \
+ $(LIBSECRET_CFLAGS) \
+ $(LIBSOUP_CFLAGS) \
$(WEBKIT2GTK_WEB_EXTENSION_CFLAGS)
libephywebextension_la_CFLAGS = \
@@ -35,11 +36,12 @@ libephywebextension_la_LDFLAGS = \
libephywebextension_la_LIBADD = \
$(top_builddir)/lib/libephymisc.la \
- $(GIO_LIBS) \
- $(GLIB_LIBS) \
- $(GTK_LIBS) \
- $(LIBSECRET_LIBS) \
- $(LIBSOUP_LIBS) \
+ $(GIO_LIBS) \
+ $(GLIB_LIBS) \
+ $(GTK_LIBS) \
+ $(HTTPSEVERYWHERE_LIBS) \
+ $(LIBSECRET_LIBS) \
+ $(LIBSOUP_LIBS) \
$(WEBKIT2GTK_WEB_EXTENSION_LIBS)
-include $(top_srcdir)/git.mk
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index 0c8c09b..3e99049 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -37,6 +37,7 @@
#include <gio/gio.h>
#include <gtk/gtk.h>
+#include <httpseverywhere-0.2.h>
#include <libsoup/soup.h>
#include <string.h>
#include <webkit2/webkit-web-extension.h>
@@ -116,13 +117,13 @@ web_page_send_request (WebKitWebPage *web_page,
{
const char *request_uri;
const char *page_uri;
+ char *new_uri;
gboolean ret;
request_uri = webkit_uri_request_get_uri (request);
if (g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_DO_NOT_TRACK)) {
SoupMessageHeaders *headers;
- char *new_uri;
headers = webkit_uri_request_get_http_headers (request);
if (headers) {
@@ -140,6 +141,20 @@ web_page_send_request (WebKitWebPage *web_page,
g_free (new_uri);
}
+ /* Rewrite URL to use HTTPS if directed by HTTPS Everywhere */
+ new_uri = https_everywhere_rewrite (request_uri);
+ if (g_strcmp0 (request_uri, new_uri) != 0) {
+ /* Workaround for https://github.com/grindhold/libhttpseverywhere/issues/8
+ * FIXME: Remove this, it's crazy!
+ */
+ if (new_uri[strlen (new_uri) - 1] == '/')
+ new_uri[strlen (new_uri) - 1] = '\0';
+ g_info ("HTTPS Everywhere: rewrote %s to %s", request_uri, new_uri);
+ webkit_uri_request_set_uri (request, new_uri);
+ request_uri = webkit_uri_request_get_uri (request);
+ }
+ g_free (new_uri);
+
if (!g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_ADBLOCK))
return FALSE;
@@ -1436,6 +1451,8 @@ ephy_web_extension_initialize (EphyWebExtension *extension,
extension->initialized = TRUE;
+ https_everywhere_init ();
+
extension->extension = g_object_ref (wk_extension);
extension->uri_tester = ephy_uri_tester_new (dot_dir);
if (!is_private_profile)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]