summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2016-07-24 12:23:42 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2016-07-24 12:23:42 +0100
commit7202ff2f649561dd98cb721bdf88b4735127bba9 (patch)
treea370d8481fde2198b7778eab7beb3ea5d4181cd8 /content
parent90a260a2ccf33a399c87b1619d3b82e19b84020f (diff)
downloadnetsurf-7202ff2f649561dd98cb721bdf88b4735127bba9.tar.gz
netsurf-7202ff2f649561dd98cb721bdf88b4735127bba9.tar.bz2
Data URL handling: Use url_unescape rather than curl.
Diffstat (limited to 'content')
-rw-r--r--content/fetchers/data.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/content/fetchers/data.c b/content/fetchers/data.c
index bbd4395d9..6b8be8dfc 100644
--- a/content/fetchers/data.c
+++ b/content/fetchers/data.c
@@ -24,9 +24,9 @@
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
-#include <curl/curl.h> /* for URL unescaping functions */
#include <libwapcaplet/libwapcaplet.h>
+#include "utils/url.h"
#include "utils/nsurl.h"
#include "utils/corestrings.h"
#include "utils/log.h"
@@ -54,21 +54,16 @@ struct fetch_data_context {
static struct fetch_data_context *ring = NULL;
-static CURL *curl;
-
static bool fetch_data_initialise(lwc_string *scheme)
{
LOG("fetch_data_initialise called for %s", lwc_string_data(scheme));
- if ( (curl = curl_easy_init()) == NULL)
- return false;
- else
- return true;
+
+ return true;
}
static void fetch_data_finalise(lwc_string *scheme)
{
LOG("fetch_data_finalise called for %s", lwc_string_data(scheme));
- curl_easy_cleanup(curl);
}
static bool fetch_data_can_fetch(const nsurl *url)
@@ -138,6 +133,7 @@ static void fetch_data_send_callback(const fetch_msg *msg,
static bool fetch_data_process(struct fetch_data_context *c)
{
+ nserror res;
fetch_msg msg;
char *params;
char *comma;
@@ -197,13 +193,14 @@ static bool fetch_data_process(struct fetch_data_context *c)
/* URL unescape the data first, just incase some insane page
* decides to nest URL and base64 encoding. Like, say, Acid2.
*/
- unescaped = curl_easy_unescape(curl, comma + 1, 0, &unescaped_len);
- if (unescaped == NULL) {
+ res = url_unescape(comma + 1, 0, &unescaped);
+ if (res != NSERROR_OK) {
msg.type = FETCH_ERROR;
msg.data.error = "Unable to URL decode data: URL";
fetch_data_send_callback(&msg, c);
return false;
}
+ unescaped_len = strlen(unescaped);
if (c->base64) {
base64_decode_alloc(unescaped, unescaped_len, &c->data, &c->datalen);
@@ -211,7 +208,7 @@ static bool fetch_data_process(struct fetch_data_context *c)
msg.type = FETCH_ERROR;
msg.data.error = "Unable to Base64 decode data: URL";
fetch_data_send_callback(&msg, c);
- curl_free(unescaped);
+ free(unescaped);
return false;
}
} else {
@@ -221,14 +218,14 @@ static bool fetch_data_process(struct fetch_data_context *c)
msg.data.error =
"Unable to allocate memory for data: URL";
fetch_data_send_callback(&msg, c);
- curl_free(unescaped);
+ free(unescaped);
return false;
}
c->datalen = unescaped_len;
memcpy(c->data, unescaped, unescaped_len);
}
- curl_free(unescaped);
+ free(unescaped);
return true;
}