Browse Source

Refuse to write relative URI references to NTriples

zrythm_meson
David Robillard 2 years ago
parent
commit
2bf875e89f
  1. 3
      NEWS
  2. 15
      src/writer.c
  3. 3
      wscript

3
NEWS

@ -2,11 +2,12 @@ serd (0.30.7) unstable; @@ -2,11 +2,12 @@ serd (0.30.7) unstable;
* Fix potential memory error when serialising URIs
* Move headers to an include directory
* Refuse to write relative URI references to NTriples
* Remove use of C character class functions that may use locale
* Split up and reorganize unit tests
* Use aligned allocation via C11 or Windows API where possible
-- David Robillard <d@drobilla.net> Fri, 13 Nov 2020 11:53:07 +0000
-- David Robillard <d@drobilla.net> Sat, 14 Nov 2020 10:53:36 +0000
serd (0.30.6) stable;

15
src/writer.c

@ -135,6 +135,12 @@ supports_abbrev(const SerdWriter* writer) @@ -135,6 +135,12 @@ supports_abbrev(const SerdWriter* writer)
return writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG;
}
static bool
supports_uriref(const SerdWriter* writer)
{
return writer->syntax == SERD_TURTLE || writer->syntax == SERD_TRIG;
}
static void
w_err(SerdWriter* writer, SerdStatus st, const char* fmt, ...)
{
@ -526,6 +532,15 @@ write_uri_node(SerdWriter* const writer, @@ -526,6 +532,15 @@ write_uri_node(SerdWriter* const writer,
}
}
if (!has_scheme && !supports_uriref(writer) &&
!serd_env_get_base_uri(writer->env, NULL)->buf) {
w_err(writer,
SERD_ERR_BAD_ARG,
"syntax does not support URI reference <%s>\n",
node->buf);
return false;
}
write_sep(writer, SEP_URI_BEGIN);
if (writer->style & SERD_STYLE_RESOLVED) {
SerdURI in_base_uri;

3
wscript

@ -588,7 +588,7 @@ def test(tst): @@ -588,7 +588,7 @@ def test(tst):
check([serdi, '%s/serd.ttl' % srcdir], stdout=os.devnull)
check([serdi, '-v'])
check([serdi, '-h'])
check([serdi, '-s', '<foo> a <#Thingie> .'])
check([serdi, '-s', '<urn:eg:s> a <urn:eg:T> .'])
check([serdi, os.devnull])
with tempfile.TemporaryFile(mode='r') as stdin:
check([serdi, '-'], stdin=stdin)
@ -609,6 +609,7 @@ def test(tst): @@ -609,6 +609,7 @@ def test(tst):
check([serdi, '-q', '%s/test/bad/bad-base.ttl' % srcdir], stderr=None)
check([serdi, '-r'])
check([serdi, '-z'])
check([serdi, '-s', '<foo> a <Bar> .'])
with tst.group('IoErrors', expected=1) as check:
check([serdi, '-e', 'file://%s/' % srcdir], name='Read directory')

Loading…
Cancel
Save