Commit a7ce46e7 authored by Michael Catanzaro's avatar Michael Catanzaro
Browse files

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.)
parent 7f96a1fe
......@@ -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])
......
......@@ -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
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment