From b244d0ec5895ff15d52f12704e5f336ad37b4473 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 13 Aug 2020 01:44:03 +0200 Subject: Refuse to write relative URIRefs to NTriples --- src/writer.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/writer.c b/src/writer.c index fe29563b..697d0e7c 100644 --- a/src/writer.c +++ b/src/writer.c @@ -165,6 +165,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 SerdStatus free_context(SerdWriter* writer) { @@ -674,6 +680,15 @@ write_uri_node(SerdWriter* const writer, } } + if (!has_scheme && !supports_uriref(writer) && + !serd_env_base_uri(writer->env)) { + SERD_LOG_ERRORF(world, + SERD_ERR_INVALID, + "syntax does not support URI reference <%s>\n", + serd_node_string(node)); + return SERD_ERR_INVALID; + } + TRY(st, esink("<", 1, writer)); if (!(writer->flags & SERD_WRITE_UNRESOLVED) && serd_env_base_uri(writer->env)) { -- cgit v1.2.1