From: Toni Gundogdu Date: Mon, 14 Oct 2013 13:24:48 +0000 (+0300) Subject: n_new, n_resolve_new: Escape URL for libcurl X-Git-Tag: v0.9.4~4^2~5 X-Git-Url: https://repo.or.cz/w/libquvi.git/commitdiff_plain/5b02675adf90675f486b0e371c8ca52ca0c3d9bc n_new, n_resolve_new: Escape URL for libcurl Escape the URLs at these chokepoints before they are passed to libcurl (via CURLOPT_URL). libcurl works with UTF8 chars as long as they have been escaped. Signed-off-by: Toni Gundogdu --- diff --git a/src/net/handle.c b/src/net/handle.c index f958994..0bc8a10 100644 --- a/src/net/handle.c +++ b/src/net/handle.c @@ -1,5 +1,5 @@ /* libquvi - * Copyright (C) 2012 Toni Gundogdu + * Copyright (C) 2012,2013 Toni Gundogdu * * This file is part of libquvi . * @@ -30,6 +30,20 @@ #include "_quvi_net_resolve_s.h" /* -- */ #include "net/handle.h" +#include "misc/url.h" + +static GString *_escaped(const gchar *url) +{ + GString *r; + gchar *e; + + /* Pass the URL in escaped form to libcurl. */ + e = m_url_escaped_form(url); + r = g_string_new(e); + g_free(e); + + return (r); +} gpointer n_new(_quvi_t q, const gchar *url) { @@ -37,7 +51,7 @@ gpointer n_new(_quvi_t q, const gchar *url) n->http_metainfo.content_type = g_string_new(NULL); n->status.errmsg = g_string_new(NULL); n->fetch.content = g_string_new(NULL); - n->url.addr = g_string_new(url); + n->url.addr = _escaped(url); n->handle.quvi = q; return (n); } @@ -69,8 +83,8 @@ gpointer n_resolve_new(_quvi_t q, const gchar *url) { _quvi_net_resolve_t r = g_new0(struct _quvi_net_resolve_s, 1); r->status.errmsg = g_string_new(NULL); - r->url.addr = g_string_new(url); r->url.dst = g_string_new(NULL); + r->url.addr = _escaped(url); r->handle.quvi = q; return (r); }