aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/writer.c15
-rw-r--r--wscript3
3 files changed, 19 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index fe031155..d4735b17 100644
--- a/NEWS
+++ b/NEWS
@@ -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;
diff --git a/src/writer.c b/src/writer.c
index 451b3e13..987d2b98 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -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,
}
}
+ 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;
diff --git a/wscript b/wscript
index c9ebcb23..4e13096a 100644
--- a/wscript
+++ b/wscript
@@ -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):
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')