summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2016-08-23 17:22:22 (GMT)
committer Chris Young <chris@unsatisfactorysoftware.co.uk>2016-08-23 17:22:22 (GMT)
commitbbbdf2e1fc1500db2762e69711a3c60d6cbfd1fb (patch)
tree79ed6cfc26fff43a346f750cc0a701e6ab6dcaf5
parent180cf8d29bb484065e4e00015e1d843fe4b43a2f (diff)
downloadnetsurf-bbbdf2e1fc1500db2762e69711a3c60d6cbfd1fb.tar.gz
netsurf-bbbdf2e1fc1500db2762e69711a3c60d6cbfd1fb.tar.bz2
Fetch relative URIs correctlychris/fetch-x-ent-ref
-rw-r--r--content/handlers/image/svg.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/content/handlers/image/svg.c b/content/handlers/image/svg.c
index 5cd3883..d6dd893 100644
--- a/content/handlers/image/svg.c
+++ b/content/handlers/image/svg.c
@@ -49,7 +49,8 @@ typedef struct svg_content {
struct svg_fetch_cb_data
{
void *parser;
- int (*cb)(void *parser, const char *data, int size);
+ nsurl *url;
+ int (*cb)(void *parser, const char *data, int size, const char *uri);
};
/** Callback for hlcache fetch */
@@ -64,14 +65,17 @@ static nserror svg_fetch_hlcache_cb(hlcache_handle *handle,
case CONTENT_MSG_DONE:
LOG("external entity '%s' retrieved", nsurl_access(hlcache_handle_get_url(handle)));
data = content_get_source_data(handle, &size);
- cb_userdata->cb(cb_userdata->parser, data, size);
+ cb_userdata->cb(cb_userdata->parser, data, size,
+ nsurl_access(cb_userdata->url));
hlcache_handle_release(handle);
+ nsurl_unref(cb_userdata->url);
free(userdata);
break;
case CONTENT_MSG_ERROR:
LOG("external entity %s error: %s", nsurl_access(hlcache_handle_get_url(handle)), event->data.error);
hlcache_handle_release(handle);
+ nsurl_unref(cb_userdata->url);
free(userdata);
break;
@@ -84,9 +88,10 @@ static nserror svg_fetch_hlcache_cb(hlcache_handle *handle,
/** Callback for libsvgtiny fetch */
static int svg_fetch_cb(void *parser, const char *base, const char *uri,
- int (*svgtiny_expat_xmlparser_parse_cb)(void *parser, const char *data, int size))
+ int (*svgtiny_expat_xmlparser_parse_cb)(void *parser, const char *data, int size, const char *uri))
{
nsurl *x_ent;
+ nsurl *base_url;
nserror ret;
hlcache_handle *handle;
struct svg_fetch_cb_data *userdata;
@@ -102,19 +107,26 @@ static int svg_fetch_cb(void *parser, const char *base, const char *uri,
userdata->cb = svgtiny_expat_xmlparser_parse_cb;
/* create url */
- /**\todo this should be nsurl_joining base+uri */
- ret = nsurl_create(uri, &x_ent);
+ ret = nsurl_create(base, &base_url);
if (ret != NSERROR_OK) {
free(userdata);
return false;
}
+ ret = nsurl_join(base_url, uri, &x_ent);
+ nsurl_unref(base_url);
+ if (ret != NSERROR_OK) {
+ free(userdata);
+ return false;
+ }
+
+ userdata->url = x_ent;
+
ret = hlcache_handle_retrieve(x_ent, 0, NULL, NULL,
svg_fetch_hlcache_cb,
userdata, /* data */
NULL, CONTENT_ANY,
&handle);
- nsurl_unref(x_ent);
if (ret != NSERROR_OK) {
return false;