aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-12-26 20:08:31 -0500
committerDavid Robillard <d@drobilla.net>2018-12-31 11:37:49 -0500
commit4a49f7d02aed06e76678da09d85cc8bc0bc3649c (patch)
tree4c03f010e453caec99fab8a27bc601d46222bd77 /src
parentef3554df938fbe419615c270573d72994f0bb67d (diff)
downloadserd-4a49f7d02aed06e76678da09d85cc8bc0bc3649c.tar.gz
serd-4a49f7d02aed06e76678da09d85cc8bc0bc3649c.tar.bz2
serd-4a49f7d02aed06e76678da09d85cc8bc0bc3649c.zip
Ensure serd_new_resolved_uri returns an absolute URI or NULL
Diffstat (limited to 'src')
-rw-r--r--src/env.c5
-rw-r--r--src/node.c16
2 files changed, 14 insertions, 7 deletions
diff --git a/src/env.c b/src/env.c
index 5a7c04fb..00585426 100644
--- a/src/env.c
+++ b/src/env.c
@@ -120,11 +120,10 @@ serd_env_set_base_uri(SerdEnv* env,
SerdNode* base_uri_node = serd_new_resolved_uri_i(
serd_node_get_string(uri), &env->base_uri);
- SerdURI base_uri;
- serd_uri_parse(serd_node_get_string(base_uri_node), &base_uri);
-
if (base_uri_node) {
// Replace the current base URI
+ SerdURI base_uri;
+ serd_uri_parse(serd_node_get_string(base_uri_node), &base_uri);
serd_node_free(env->base_uri_node);
env->base_uri_node = base_uri_node;
env->base_uri = base_uri;
diff --git a/src/node.c b/src/node.c
index 36b1af79..859cb0a3 100644
--- a/src/node.c
+++ b/src/node.c
@@ -359,14 +359,22 @@ serd_node_resolve(const SerdNode* node, const SerdNode* base)
SerdNode*
serd_new_resolved_uri_i(const char* str, const SerdURI* base)
{
+ SerdNode* result = NULL;
if (!str || str[0] == '\0') {
// Empty URI => Base URI, or nothing if no base is given
- return base ? serd_new_from_uri(base, NULL) : NULL;
+ result = base ? serd_new_from_uri(base, NULL) : NULL;
+ } else {
+ SerdURI uri;
+ serd_uri_parse(str, &uri);
+ result = serd_new_from_uri(&uri, base);
}
- SerdURI uri;
- serd_uri_parse(str, &uri);
- return serd_new_from_uri(&uri, base);
+ if (!serd_uri_string_has_scheme(serd_node_get_string(result))) {
+ serd_node_free(result);
+ return NULL;
+ }
+
+ return result;
}
static inline bool