From a208ffd4776ebc9072bfca2603d6931e24917ccf Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 23 Mar 2017 21:39:16 +0100 Subject: Don't attempt to load remote or non-Turtle files --- NEWS | 3 ++- src/world.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 8803e25..04c167e 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ lilv (0.24.3) unstable; + * Don't attempt to load remote or non-Turtle files * lv2bench: Improve support for plugins with sequence ports * lv2bench: Support running a single plugin given on the command line * Gracefully handle plugins with missing binary URIs @@ -7,7 +8,7 @@ lilv (0.24.3) unstable; * Install Python bindings when configured without tests (thanks Clement Skau) - -- David Robillard Sat, 18 Mar 2017 17:02:35 +0100 + -- David Robillard Thu, 23 Mar 2017 21:37:42 +0100 lilv (0.24.2) stable; 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; -- cgit v1.2.1