[evolution-patches] Re: [Evolution-hackers] Libsoup encode problem



Hi, Dan,

   I've hacked soup-uri.[ch], and made a patch to solve the problem.

   Would you please help me to review the patch?

   Thanks.

Best Regards.

Alfred Peng


Dan Winship wrote:

On Thu, 2004-07-29 at 10:25 +0800, Harry Lu wrote:
http://jsun.mcom.com/storeevents.wcap?
id=b5q2o8ve2rk02nv9t6&calid=jsun&uid=333&dtstart=19990301T112233Z&rrules="count%3D10%3Bfreq%3Ddaily";"freq%3Dweekly%3Bcount%3D4"&dtend=19990301T112233&summary=uuuu

When we use libsoup to send the URL, libsoup encodes the " in the
rule, so the server cannot recognize this field correctly.  Yes, I
admit the server is broken here. But do we have a way to not encode
the URL?

No. You would need to hack up soup-uri.c.

-- Dan


_______________________________________________
evolution-hackers maillist  -  evolution-hackers lists ximian com
http://lists.ximian.com/mailman/listinfo/evolution-hackers

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libsoup/ChangeLog,v
retrieving revision 1.438
diff -u -r1.438 ChangeLog
--- ChangeLog	19 Jul 2004 20:07:18 -0000	1.438
+++ ChangeLog	2 Aug 2004 09:23:47 -0000
@@ -1,3 +1,12 @@
+2004-08-02  Alfred Peng  <alfred peng sun com>
+
+	* libsoup/soup-uri.h:
+	Add flag "encoded" to SoupUri.
+	* libsoup/soup-uri.c: (append_uri), (soup_uri_new),
+	(soup_uri_to_string), (soup_uri_copy), (soup_uri_equal):
+	If the flag "encoded" of SoupUri is TRUE, don't encode the 
+	message again.
+
 2004-07-19  JP Rosevear  <jpr novell com>
 
 	* configure.in: bump version, libtool number
Index: libsoup/soup-uri.c
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-uri.c,v
retrieving revision 1.29
diff -u -r1.29 soup-uri.c
--- libsoup/soup-uri.c	7 Jul 2004 15:27:24 -0000	1.29
+++ libsoup/soup-uri.c	2 Aug 2004 09:23:47 -0000
@@ -42,6 +42,15 @@
 
 static void append_uri_encoded (GString *str, const char *in, const char *extra_enc_chars);
 
+static inline void
+append_uri (GString *str, const char *in, const char *extra_enc_chars, gboolean encoded)
+{
+	if (encoded)
+		g_string_append (str, in);
+	else
+		append_uri_encoded (str, in, extra_enc_chars);
+}
+
 /**
  * soup_uri_new_with_base:
  * @base: a base URI
@@ -252,6 +261,8 @@
 		return NULL;
 	}
 
+	uri->encoded = FALSE;
+
 	return uri;
 }
 
@@ -279,10 +290,10 @@
 	if (uri->host && !just_path) {
 		g_string_append (str, "//");
 		if (uri->user) {
-			append_uri_encoded (str, uri->user, ":;@/");
+			append_uri (str, uri->user, ":;@/", uri->encoded);
 			g_string_append_c (str, '@');
 		}
-		append_uri_encoded (str, uri->host, ":/");
+		append_uri (str, uri->host, ":/", uri->encoded);
 		if (uri->port && uri->port != soup_protocol_default_port (uri->protocol))
 			g_string_append_printf (str, ":%d", uri->port);
 		if (!uri->path && (uri->query || uri->fragment))
@@ -290,17 +301,17 @@
 	}
 
 	if (uri->path && *uri->path)
-		append_uri_encoded (str, uri->path, "?");
+		append_uri (str, uri->path, "?", uri->encoded);
 	else if (just_path)
 		g_string_append_c (str, '/');
 
 	if (uri->query) {
 		g_string_append_c (str, '?');
-		append_uri_encoded (str, uri->query, NULL);
+		append_uri (str, uri->query, NULL, uri->encoded);
 	}
 	if (uri->fragment && !just_path) {
 		g_string_append_c (str, '#');
-		append_uri_encoded (str, uri->fragment, NULL);
+		append_uri (str, uri->fragment, NULL, uri->encoded);
 	}
 
 	return_result = str->str;
@@ -325,6 +336,7 @@
 	dup->path     = g_strdup (uri->path);
 	dup->query    = g_strdup (uri->query);
 	dup->fragment = g_strdup (uri->fragment);
+	dup->encoded  = uri->encoded;
 
 	return dup;
 }
@@ -359,6 +371,7 @@
 {
 	if (u1->protocol != u2->protocol              ||
 	    u1->port     != u2->port                  ||
+		u1->encoded	 != u2->encoded				  ||
 	    !parts_equal (u1->user, u2->user)         ||
 	    !parts_equal (u1->passwd, u2->passwd)     ||
 	    !parts_equal (u1->host, u2->host)         ||
Index: libsoup/soup-uri.h
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-uri.h,v
retrieving revision 1.17
diff -u -r1.17 soup-uri.h
--- libsoup/soup-uri.h	10 Sep 2003 21:39:06 -0000	1.17
+++ libsoup/soup-uri.h	2 Aug 2004 09:23:47 -0000
@@ -28,6 +28,7 @@
 	char         *query;
 
 	char         *fragment;
+	gboolean	  encoded;
 };
 
 SoupUri  *soup_uri_new_with_base     (const SoupUri *base,


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