[evolution/webkit: 133/182] Escape query parameters in mail:// request URI (fixes #668658)



commit 9cdb367db92aedc7ba8f893a5c787ef276897762
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Jan 26 13:37:19 2012 +0100

    Escape query parameters in mail:// request URI (fixes #668658)

 em-format/Makefile.am |    6 ++++--
 em-format/em-format.c |   12 +++++++++---
 mail/e-mail-request.c |    5 +++++
 3 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/em-format/Makefile.am b/em-format/Makefile.am
index 278bcb2..392a195 100644
--- a/em-format/Makefile.am
+++ b/em-format/Makefile.am
@@ -13,7 +13,8 @@ libemformat_la_CPPFLAGS =				\
 	-I$(top_srcdir)					\
 	-I$(top_srcdir)/widgets				\
 	$(EVOLUTION_DATA_SERVER_CFLAGS)			\
-	$(GNOME_PLATFORM_CFLAGS)
+	$(GNOME_PLATFORM_CFLAGS)			\
+	$(LIBSOUP_CFLAGS)
 
 libemformat_la_SOURCES =				\
 	$(emformatinclude_HEADERS)			\
@@ -28,6 +29,7 @@ libemformat_la_LIBADD =					\
 	$(top_builddir)/e-util/libeutil.la		\
 	$(top_builddir)/shell/libeshell.la		\
 	$(EVOLUTION_DATA_SERVER_LIBS)			\
-	$(GNOME_PLATFORM_LIBS)
+	$(GNOME_PLATFORM_LIBS)				\
+	$(LIBSOUP_LIBS)
 
 -include $(top_srcdir)/git.mk
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 20ac4e4..e74ef51 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -28,6 +28,7 @@
 #include <string.h>
 #include <gio/gio.h>
 #include <glib/gi18n-lib.h>
+#include <libsoup/soup-uri.h>
 
 #include "em-format.h"
 #include "e-util/e-util.h"
@@ -2439,18 +2440,23 @@ em_format_build_mail_uri (CamelFolder *folder,
 			case G_TYPE_INT:
 			case G_TYPE_BOOLEAN: {
 				gint val = va_arg (ap, int);
-				tmp2 = g_strdup_printf ("%s%c%s=%d", tmp, separator, name, val);
+				tmp2 = g_strdup_printf ("%s%c%s=%d", tmp,
+                                                separator, name, val);
 				break;
 			}
 			case G_TYPE_FLOAT:
 			case G_TYPE_DOUBLE: {
 				gdouble val = va_arg (ap, double);
-				tmp2 = g_strdup_printf ("%s%c%s=%f", tmp, separator, name, val);
+				tmp2 = g_strdup_printf ("%s%c%s=%f", tmp,
+                                                separator, name, val);
 				break;
 			}
 			case G_TYPE_STRING: {
 				gchar *val = va_arg (ap, char *);
-				tmp2 = g_strdup_printf ("%s%c%s=%s", tmp, separator, name, val);
+                                gchar *escaped = soup_uri_encode (val, NULL);
+				tmp2 = g_strdup_printf ("%s%c%s=%s", tmp,
+                                                separator, name, escaped);
+                                g_free (escaped);
 				break;
 			}
 			default:
diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c
index a80c410..ea59a6d 100644
--- a/mail/e-mail-request.c
+++ b/mail/e-mail-request.c
@@ -58,7 +58,10 @@ handle_mail_request (GSimpleAsyncResult *res,
 	part_id = g_hash_table_lookup (request->priv->uri_query, "part_id");
 
 	if (part_id) {
+                /* original part_id is owned by the GHashTable */
+                part_id = soup_uri_decode (part_id);
 		request->priv->puri = em_format_find_puri (emf, part_id);
+
 		if (request->priv->puri) {
 			EMFormatWriterInfo info = {0};
 			gchar *val;
@@ -85,6 +88,8 @@ handle_mail_request (GSimpleAsyncResult *res,
 		} else {
 			g_warning ("Failed to lookup requested part '%s' - this should not happen!", part_id);
 		}
+
+		g_free (part_id);
 	}
 
 	/* Convert the GString to GInputStream and send it back to WebKit */



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