[couchdb-glib/wip/query-response: 2/2] Add couchdb_encode_uri functions
- From: Krzysztof Klimonda <kklimonda src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [couchdb-glib/wip/query-response: 2/2] Add couchdb_encode_uri functions
- Date: Fri, 19 Nov 2010 16:33:01 +0000 (UTC)
commit 2789c98a76a0f54feb66f1f0e49a7929a8357d0d
Author: Krzysztof Klimonda <kklimonda syntaxhighlighted com>
Date: Fri Nov 19 17:29:18 2010 +0100
Add couchdb_encode_uri functions
This function is used by couchdb_query_get_query_options_string
and will be used by some other methods of CouchdbDatabase and
CouchdbSession classes to escape strings that have to be passed
as a query in uri.
couchdb-glib/utils.c | 10 ++++++++++
couchdb-glib/utils.h | 2 ++
2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/couchdb-glib/utils.c b/couchdb-glib/utils.c
index d5fcd0a..71bab91 100644
--- a/couchdb-glib/utils.c
+++ b/couchdb-glib/utils.c
@@ -22,6 +22,7 @@
#include <uuid/uuid.h>
#include <string.h>
#include <libsoup/soup-session-async.h>
+#include <libsoup/soup-uri.h>
#include "couchdb-glib.h"
#include "utils.h"
@@ -48,6 +49,15 @@ generate_uuid (void)
return g_strdup (uuid_string);
}
+/* following characters have to be explicitly added
+ * to soup_uri_encode call as it doesn't escape
+ * sub-delims defined in RFC 3986, part 2.2. */
+gchar *
+couchdb_uri_encode (const gchar *uri)
+{
+ return soup_uri_encode (uri, "&;_$()+-");
+}
+
GType
get_type_from_field (JsonObject *json_object, const gchar *field)
{
diff --git a/couchdb-glib/utils.h b/couchdb-glib/utils.h
index 316f6e4..27b30cf 100644
--- a/couchdb-glib/utils.h
+++ b/couchdb-glib/utils.h
@@ -40,6 +40,8 @@ char* generate_uuid (void);
GType get_type_from_field (JsonObject *object, const char *field);
+gchar *couchdb_uri_encode (const gchar *uri);
+
/* Private API */
gboolean couchdb_session_send_message (CouchdbSession *session,
const char *method,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]