summaryrefslogtreecommitdiff
path: root/libsoup
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-10-10 09:31:23 -0400
committerDan Winship <danw@gnome.org>2013-10-10 09:33:26 -0400
commite5fbda83f6045a610054b179ae60fc062bded101 (patch)
tree2e95d49c9556b465b944e96447fd3943a3d37349 /libsoup
parent1e0656f8ceb6fb1eb019f3b083d3dfe610032b68 (diff)
downloadlibsoup-e5fbda83f6045a610054b179ae60fc062bded101.tar.gz
soup-uri: minor code reorg/renaming
Change uri_decoded_copy() to strdup the input string *after* doing its g_return_val_if_fail(), to avoid pointlessly confusing code analyzers. Also, rename the function to soup_uri_decoded_copy(), since it's used from soup-request-data.c too and it's been annoying me that it was non-namespaced. https://bugzilla.gnome.org/show_bug.cgi?id=709793
Diffstat (limited to 'libsoup')
-rw-r--r--libsoup/soup-misc-private.h2
-rw-r--r--libsoup/soup-request-data.c5
-rw-r--r--libsoup/soup-uri.c25
3 files changed, 18 insertions, 14 deletions
diff --git a/libsoup/soup-misc-private.h b/libsoup/soup-misc-private.h
index e9c83f61..7ea2cdea 100644
--- a/libsoup/soup-misc-private.h
+++ b/libsoup/soup-misc-private.h
@@ -10,7 +10,7 @@
#include "soup-socket.h"
#include "soup-message-headers.h"
-char *uri_decoded_copy (const char *str, int length, int *decoded_length);
+char *soup_uri_decoded_copy (const char *str, int length, int *decoded_length);
char *soup_uri_to_string_internal (SoupURI *uri, gboolean just_path_and_query,
gboolean force_port);
gboolean soup_uri_is_http (SoupURI *uri, char **aliases);
diff --git a/libsoup/soup-request-data.c b/libsoup/soup-request-data.c
index 246854a7..678e84da 100644
--- a/libsoup/soup-request-data.c
+++ b/libsoup/soup-request-data.c
@@ -96,7 +96,7 @@ soup_request_data_send (SoupRequest *request,
end = comma;
if (end != start)
- data->priv->content_type = uri_decoded_copy (start, end - start, NULL);
+ data->priv->content_type = soup_uri_decoded_copy (start, end - start, NULL);
}
memstream = g_memory_input_stream_new ();
@@ -106,7 +106,8 @@ soup_request_data_send (SoupRequest *request,
if (*start) {
int decoded_length = 0;
- guchar *buf = (guchar *) uri_decoded_copy (start, strlen (start), &decoded_length);
+ guchar *buf = (guchar *) soup_uri_decoded_copy (start, strlen (start),
+ &decoded_length);
if (base64)
buf = g_base64_decode_inplace ((gchar*) buf, &data->priv->content_length);
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c
index 808d2ccc..e3092dcf 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri.c
@@ -293,15 +293,15 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string)
if (at && at < path) {
colon = strchr (uri_string, ':');
if (colon && colon < at) {
- uri->password = uri_decoded_copy (colon + 1,
- at - colon - 1, NULL);
+ uri->password = soup_uri_decoded_copy (colon + 1,
+ at - colon - 1, NULL);
} else {
uri->password = NULL;
colon = at;
}
- uri->user = uri_decoded_copy (uri_string,
- colon - uri_string, NULL);
+ uri->user = soup_uri_decoded_copy (uri_string,
+ colon - uri_string, NULL);
uri_string = at + 1;
} else
uri->user = uri->password = NULL;
@@ -322,14 +322,16 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string)
colon = NULL;
pct = memchr (uri_string, '%', hostend - uri_string);
- if (!pct || (pct[1] == '2' && pct[2] == '5'))
- uri->host = uri_decoded_copy (uri_string, hostend - uri_string, NULL);
- else
+ if (!pct || (pct[1] == '2' && pct[2] == '5')) {
+ uri->host = soup_uri_decoded_copy (uri_string,
+ hostend - uri_string, NULL);
+ } else
uri->host = g_strndup (uri_string, hostend - uri_string);
} else {
colon = memchr (uri_string, ':', path - uri_string);
hostend = colon ? colon : path;
- uri->host = uri_decoded_copy (uri_string, hostend - uri_string, NULL);
+ uri->host = soup_uri_decoded_copy (uri_string,
+ hostend - uri_string, NULL);
}
if (colon && colon != path - 1) {
@@ -719,13 +721,14 @@ soup_uri_encode (const char *part, const char *escape_extra)
#define HEXCHAR(s) ((XDIGIT (s[1]) << 4) + XDIGIT (s[2]))
char *
-uri_decoded_copy (const char *part, int length, int *decoded_length)
+soup_uri_decoded_copy (const char *part, int length, int *decoded_length)
{
unsigned char *s, *d;
- char *decoded = g_strndup (part, length);
+ char *decoded;
g_return_val_if_fail (part != NULL, NULL);
+ decoded = g_strndup (part, length);
s = d = (unsigned char *)decoded;
do {
if (*s == '%') {
@@ -763,7 +766,7 @@ soup_uri_decode (const char *part)
{
g_return_val_if_fail (part != NULL, NULL);
- return uri_decoded_copy (part, strlen (part), NULL);
+ return soup_uri_decoded_copy (part, strlen (part), NULL);
}
static char *