aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-14 11:52:57 +0100
committerDavid Robillard <d@drobilla.net>2020-11-14 11:54:54 +0100
commit2bf875e89f98c64164f563a8d1fae2851d9c023c (patch)
tree7ae6acaa6ee6c272e95e0c257d3c7e922968a0a0 /src/writer.c
parent6be4a34047af74c984dc644b4157da0b45c6dd83 (diff)
downloadserd-2bf875e89f98c64164f563a8d1fae2851d9c023c.tar.gz
serd-2bf875e89f98c64164f563a8d1fae2851d9c023c.tar.bz2
serd-2bf875e89f98c64164f563a8d1fae2851d9c023c.zip
Refuse to write relative URI references to NTriples
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c15
1 files changed, 15 insertions, 0 deletions
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;