Blob Blame History Raw
diff -up evolution-3.22.6/mail/e-http-request.c.remote-content-cache evolution-3.22.6/mail/e-http-request.c
--- evolution-3.22.6/mail/e-http-request.c.remote-content-cache	2016-09-19 10:22:58.000000000 +0200
+++ evolution-3.22.6/mail/e-http-request.c	2017-03-24 13:47:48.814647889 +0100
@@ -186,7 +186,7 @@ e_http_request_process_sync (EContentReq
 			     GError **error)
 {
 	SoupURI *soup_uri;
-	gchar *evo_uri, *use_uri;
+	gchar *evo_uri = NULL, *use_uri;
 	gchar *mail_uri = NULL;
 	GInputStream *stream;
 	gboolean force_load_images = FALSE;
@@ -221,6 +221,14 @@ e_http_request_process_sync (EContentReq
 
 		g_hash_table_remove (query, "__evo-mail");
 
+		/* Required, because soup_uri_set_query_from_form() can change
+		   order of arguments, then the URL checksum doesn't match. */
+		evo_uri = g_hash_table_lookup (query, "__evo-original-uri");
+		if (evo_uri)
+			evo_uri = g_strdup (evo_uri);
+
+		g_hash_table_remove (query, "__evo-original-uri");
+
 		/* Remove __evo-load-images if present (and in such case set
 		 * force_load_images to TRUE) */
 		force_load_images = g_hash_table_remove (query, "__evo-load-images");
@@ -229,7 +237,8 @@ e_http_request_process_sync (EContentReq
 		g_hash_table_unref (query);
 	}
 
-	evo_uri = soup_uri_to_string (soup_uri, FALSE);
+	if (!evo_uri)
+		evo_uri = soup_uri_to_string (soup_uri, FALSE);
 
 	if (camel_debug_start ("emformat:requests")) {
 		printf (
diff -up evolution-3.22.6/mail/e-mail-display.c.remote-content-cache evolution-3.22.6/mail/e-mail-display.c
--- evolution-3.22.6/mail/e-mail-display.c.remote-content-cache	2017-03-24 13:47:48.803647890 +0100
+++ evolution-3.22.6/mail/e-mail-display.c	2017-03-24 13:47:48.814647889 +0100
@@ -1745,6 +1745,10 @@ mail_display_uri_requested_cb (EWebView
 		enc = soup_uri_encode (mail_uri, NULL);
 		g_hash_table_insert (query, g_strdup ("__evo-mail"), enc);
 
+		/* Required, because soup_uri_set_query_from_form() can change
+		   order of arguments, then the URL checksum doesn't match. */
+		g_hash_table_insert (query, g_strdup ("__evo-original-uri"), g_strdup (uri));
+
 		if (display->priv->force_image_load || can_download_uri) {
 			g_hash_table_insert (
 				query,
diff -up evolution-3.22.6/modules/webkit-editor/e-webkit-editor.c.remote-content-cache evolution-3.22.6/modules/webkit-editor/e-webkit-editor.c
--- evolution-3.22.6/modules/webkit-editor/e-webkit-editor.c.remote-content-cache	2017-03-24 13:47:48.804647890 +0100
+++ evolution-3.22.6/modules/webkit-editor/e-webkit-editor.c	2017-03-24 13:50:26.450640886 +0100
@@ -23,6 +23,8 @@
 #include "web-extension/e-editor-web-extension-names.h"
 
 #include <e-util/e-util.h>
+#include "mail/e-http-request.h"
+
 #include <string.h>
 
 #define E_WEBKIT_EDITOR_GET_PRIVATE(obj) \
@@ -4989,9 +4991,58 @@ webkit_editor_get_web_extension (EWebKit
 }
 
 static void
+webkit_editor_uri_request_done_cb (GObject *source_object,
+				   GAsyncResult *result,
+				   gpointer user_data)
+{
+	WebKitURISchemeRequest *request = user_data;
+	GInputStream *stream = NULL;
+	gint64 stream_length = -1;
+	gchar *mime_type = NULL;
+	GError *error = NULL;
+
+	g_return_if_fail (E_IS_CONTENT_REQUEST (source_object));
+	g_return_if_fail (WEBKIT_IS_URI_SCHEME_REQUEST (request));
+
+	if (!e_content_request_process_finish (E_CONTENT_REQUEST (source_object),
+		result, &stream, &stream_length, &mime_type, &error)) {
+		webkit_uri_scheme_request_finish_error (request, error);
+		g_clear_error (&error);
+	} else {
+		webkit_uri_scheme_request_finish (request, stream, stream_length, mime_type);
+
+		g_clear_object (&stream);
+		g_free (mime_type);
+	}
+
+	g_object_unref (request);
+}
+
+static void
+webkit_editor_process_uri_request_cb (WebKitURISchemeRequest *request,
+				      gpointer user_data)
+{
+	EContentRequest *content_request = user_data;
+	const gchar *uri;
+	GObject *requester;
+
+	g_return_if_fail (WEBKIT_IS_URI_SCHEME_REQUEST (request));
+	g_return_if_fail (E_IS_CONTENT_REQUEST (content_request));
+
+	uri = webkit_uri_scheme_request_get_uri (request);
+	requester = G_OBJECT (webkit_uri_scheme_request_get_web_view (request));
+
+	g_return_if_fail (e_content_request_can_process_uri (content_request, uri));
+
+	e_content_request_process (content_request, uri, requester, NULL,
+		webkit_editor_uri_request_done_cb, g_object_ref (request));
+}
+
+static void
 webkit_editor_constructed (GObject *object)
 {
 	EWebKitEditor *wk_editor;
+	EContentRequest *content_request;
 	gchar **languages;
 	WebKitWebContext *web_context;
 	WebKitSettings *web_settings;
@@ -5012,6 +5063,13 @@ webkit_editor_constructed (GObject *obje
 	webkit_web_context_set_spell_checking_languages (web_context, (const gchar * const *) languages);
 	g_strfreev (languages);
 
+	content_request = e_http_request_new ();
+	webkit_web_context_register_uri_scheme (web_context, "evo-http", webkit_editor_process_uri_request_cb,
+		g_object_ref (content_request), g_object_unref);
+	webkit_web_context_register_uri_scheme (web_context, "evo-https", webkit_editor_process_uri_request_cb,
+		g_object_ref (content_request), g_object_unref);
+	g_object_unref (content_request);
+
 	webkit_web_view_set_editable (web_view, TRUE);
 
 	web_settings = webkit_web_view_get_settings (web_view);
diff -up evolution-3.22.6/modules/webkit-editor/Makefile.am.remote-content-cache evolution-3.22.6/modules/webkit-editor/Makefile.am
--- evolution-3.22.6/modules/webkit-editor/Makefile.am.remote-content-cache	2017-03-24 13:51:12.164638855 +0100
+++ evolution-3.22.6/modules/webkit-editor/Makefile.am	2017-03-24 13:51:23.553638350 +0100
@@ -21,6 +21,7 @@ module_webkit_editor_la_SOURCES = \
 
 module_webkit_editor_la_LIBADD = \
 	$(top_builddir)/e-util/libevolution-util.la	\
+	$(top_builddir)/mail/libevolution-mail.la	\
 	$(EVOLUTION_DATA_SERVER_LIBS)			\
 	$(GNOME_PLATFORM_LIBS)				\
 	$(NULL)