summaryrefslogtreecommitdiff
path: root/libsoup/soup-request-data.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2010-12-12 11:50:57 +0100
committerDan Winship <danw@gnome.org>2010-12-12 11:50:57 +0100
commit919d6b97583c0541f92439d08195ee9a77011515 (patch)
tree32320ba16136f78782666836a2581d1cd943d5db /libsoup/soup-request-data.c
parentb355e0c224b165d9227fb2a07795178c6e0de8ac (diff)
downloadlibsoup-919d6b97583c0541f92439d08195ee9a77011515.tar.gz
soup-request-data: Fix content-type decoding
Given "data:text/html,<html>...", it was reporting the content-type as "data:text/html". Fix. https://bugs.webkit.org/show_bug.cgi?id=50885
Diffstat (limited to 'libsoup/soup-request-data.c')
-rw-r--r--libsoup/soup-request-data.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/libsoup/soup-request-data.c b/libsoup/soup-request-data.c
index 188a0cb3..3a1f0a60 100644
--- a/libsoup/soup-request-data.c
+++ b/libsoup/soup-request-data.c
@@ -64,6 +64,9 @@ soup_request_data_check_uri (SoupRequest *request,
return uri->host == NULL;
}
+#define BASE64_INDICATOR ";base64"
+#define BASE64_INDICATOR_LEN (sizeof (";base64") - 1)
+
static GInputStream *
soup_request_data_send (SoupRequest *request,
GCancellable *cancellable,
@@ -72,22 +75,23 @@ soup_request_data_send (SoupRequest *request,
SoupRequestData *data = SOUP_REQUEST_DATA (request);
SoupURI *uri = soup_request_get_uri (request);
GInputStream *memstream;
- const char *comma, *semi, *start, *end;
+ const char *comma, *start, *end;
gboolean base64 = FALSE;
char *uristr;
uristr = soup_uri_to_string (uri, FALSE);
- comma = strchr (uristr, ',');
- if (comma && comma != uristr) {
+ start = uristr + 5;
+ comma = strchr (start, ',');
+ if (comma && comma != start) {
/* Deal with MIME type / params */
- semi = memchr (uristr, ';', comma - uristr);
- end = semi ? semi : comma;
-
- if (semi && !g_ascii_strncasecmp (semi, ";base64", MAX ((size_t) (comma - semi), strlen (";base64"))))
+ if (comma > start + BASE64_INDICATOR_LEN && !g_ascii_strncasecmp (comma - BASE64_INDICATOR_LEN, BASE64_INDICATOR, BASE64_INDICATOR_LEN)) {
+ end = comma - BASE64_INDICATOR_LEN;
base64 = TRUE;
+ } else
+ end = comma;
- if (end != uristr) {
- data->priv->content_type = g_strndup (uristr, end - uristr);
+ if (end != start) {
+ data->priv->content_type = g_strndup (start, end - start);
if (!base64)
soup_uri_decode (data->priv->content_type);
}
@@ -95,7 +99,8 @@ soup_request_data_send (SoupRequest *request,
memstream = g_memory_input_stream_new ();
- start = comma ? comma + 1 : uristr;
+ if (comma)
+ start = comma + 1;
if (*start) {
guchar *buf;