diff options
author | David Robillard <d@drobilla.net> | 2020-11-14 11:52:57 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-14 11:54:54 +0100 |
commit | 2bf875e89f98c64164f563a8d1fae2851d9c023c (patch) | |
tree | 7ae6acaa6ee6c272e95e0c257d3c7e922968a0a0 /src | |
parent | 6be4a34047af74c984dc644b4157da0b45c6dd83 (diff) | |
download | serd-2bf875e89f98c64164f563a8d1fae2851d9c023c.tar.gz serd-2bf875e89f98c64164f563a8d1fae2851d9c023c.tar.bz2 serd-2bf875e89f98c64164f563a8d1fae2851d9c023c.zip |
Refuse to write relative URI references to NTriples
Diffstat (limited to 'src')
-rw-r--r-- | src/writer.c | 15 |
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; |