[libsoup] Fix parsing/generation of URI queries that aren't HTML forms
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] Fix parsing/generation of URI queries that aren't HTML forms
- Date: Tue, 9 Nov 2010 17:30:46 +0000 (UTC)
commit 82b45228b517c05c36992ff63bc26e91df473a80
Author: Dan Winship <danw gnome org>
Date: Tue Nov 9 12:23:10 2010 -0500
Fix parsing/generation of URI queries that aren't HTML forms
soup_form_decode() used to accept strings that weren't "name=value"
pairs, but soup_form_encode_hash() would crash if you passed the
resulting GHashTable to it. Fix both sides: now soup_form_decode()
ignores non-"name=value" elements, and soup_form_encode_hash()
g_return_if_fail()s rather than crashing.
Also fix use of deprecated soup-form.h method names in soup-uri.c and
soup-server.c
https://bugzilla.gnome.org/show_bug.cgi?id=620220
libsoup/soup-form.c | 5 ++++-
libsoup/soup-server.c | 2 +-
libsoup/soup-uri.c | 7 ++++---
3 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/libsoup/soup-form.c b/libsoup/soup-form.c
index 1523f5a..59bfd28 100644
--- a/libsoup/soup-form.c
+++ b/libsoup/soup-form.c
@@ -100,7 +100,7 @@ soup_form_decode (const char *encoded_form)
value = eq + 1;
} else
value = NULL;
- if (!form_decode (name) || (value && !form_decode (value))) {
+ if (!value || !form_decode (name) || !form_decode (value)) {
g_free (name);
continue;
}
@@ -226,6 +226,9 @@ append_form_encoded (GString *str, const char *in)
static void
encode_pair (GString *str, const char *name, const char *value)
{
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (value != NULL);
+
if (str->len)
g_string_append_c (str, '&');
append_form_encoded (str, name);
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index e60ede9..80ad546 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -837,7 +837,7 @@ call_handler (SoupMessage *req, SoupClientContext *client)
GHashTable *form_data_set;
if (uri->query)
- form_data_set = soup_form_decode_urlencoded (uri->query);
+ form_data_set = soup_form_decode (uri->query);
else
form_data_set = NULL;
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c
index 04e87e1..dcffd33 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri.c
@@ -68,7 +68,7 @@
* #SoupURI will have a @path of "/".
*
* @query and @fragment are optional for all URI types.
- * soup_form_decode_urlencoded() may be useful for parsing @query.
+ * soup_form_decode() may be useful for parsing @query.
*
* Note that @path, @query, and @fragment may contain
* %<!-- -->-encoded characters. soup_uri_new() calls
@@ -980,7 +980,8 @@ soup_uri_set_query (SoupURI *uri, const char *query)
/**
* soup_uri_set_query_from_form:
* @uri: a #SoupURI
- * @form: (element-type utf8 utf8): a #GHashTable containing HTML form information
+ * @form: (element-type utf8 utf8): a #GHashTable containing HTML form
+ * information
*
* Sets @uri's query to the result of encoding @form according to the
* HTML form rules. See soup_form_encode_hash() for more information.
@@ -989,7 +990,7 @@ void
soup_uri_set_query_from_form (SoupURI *uri, GHashTable *form)
{
g_free (uri->query);
- uri->query = soup_form_encode_urlencoded (form);
+ uri->query = soup_form_encode_hash (form);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]