summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-03-23 21:39:16 +0100
committerDavid Robillard <d@drobilla.net>2017-03-23 21:39:16 +0100
commita208ffd4776ebc9072bfca2603d6931e24917ccf (patch)
treed0e38e8a3d40ff6d11bb530d8bbd48306f859031 /src
parent3ee07e807b3e5490fa274241f7f0552ede133f17 (diff)
downloadlilv-a208ffd4776ebc9072bfca2603d6931e24917ccf.tar.gz
lilv-a208ffd4776ebc9072bfca2603d6931e24917ccf.tar.bz2
lilv-a208ffd4776ebc9072bfca2603d6931e24917ccf.zip
Don't attempt to load remote or non-Turtle files
Diffstat (limited to 'src')
-rw-r--r--src/world.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/world.c b/src/world.c
index 622e0a5..a053b0d 100644
--- a/src/world.c
+++ b/src/world.c
@@ -1046,9 +1046,17 @@ lilv_world_load_file(LilvWorld* world, SerdReader* reader, const LilvNode* uri)
return SERD_FAILURE; // File has already been loaded
}
+ size_t uri_len;
+ const uint8_t* const uri_str = sord_node_get_string_counted(
+ uri->node, &uri_len);
+ if (strncmp((const char*)uri_str, "file:", 5)) {
+ return SERD_FAILURE; // Not a local file
+ } else if (strcmp((const char*)uri_str + uri_len - 4, ".ttl")) {
+ return SERD_FAILURE; // Not a Turtle file
+ }
+
serd_reader_add_blank_prefix(reader, lilv_world_blank_node_prefix(world));
- const SerdStatus st = serd_reader_read_file(
- reader, sord_node_get_string(uri->node));
+ const SerdStatus st = serd_reader_read_file(reader, uri_str);
if (st) {
LILV_ERRORF("Error loading file `%s'\n", lilv_node_as_string(uri));
return st;