diff options
author | David Robillard <d@drobilla.net> | 2017-03-23 21:39:16 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-03-23 21:39:16 +0100 |
commit | a208ffd4776ebc9072bfca2603d6931e24917ccf (patch) | |
tree | d0e38e8a3d40ff6d11bb530d8bbd48306f859031 | |
parent | 3ee07e807b3e5490fa274241f7f0552ede133f17 (diff) | |
download | lilv-a208ffd4776ebc9072bfca2603d6931e24917ccf.tar.gz lilv-a208ffd4776ebc9072bfca2603d6931e24917ccf.tar.bz2 lilv-a208ffd4776ebc9072bfca2603d6931e24917ccf.zip |
Don't attempt to load remote or non-Turtle files
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/world.c | 12 |
2 files changed, 12 insertions, 3 deletions
@@ -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 <d@drobilla.net> Sat, 18 Mar 2017 17:02:35 +0100 + -- David Robillard <d@drobilla.net> 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; |