aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/reader.c15
2 files changed, 16 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index b1cb13af..b9bfe65b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,11 @@
serd (0.29.2) unstable;
* Support strict parsing of prefixed names
+ * Report errors for directives or abbreviations in NTriples or NQuads
* Report errors for prematurely terminated statements
* Fix building with MSVC
- -- David Robillard <d@drobilla.net> Mon, 28 Aug 2017 12:39:47 +0200
+ -- David Robillard <d@drobilla.net> Sat, 23 Sep 2017 13:54:10 +0200
serd (0.28.0) stable;
diff --git a/src/reader.c b/src/reader.c
index 90f2d3dd..a8339a89 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -1293,6 +1293,11 @@ static bool
read_objectList(SerdReader* reader, ReadContext ctx, bool* ate_dot)
{
TRY_RET(read_object(reader, &ctx, true, ate_dot));
+ if (!fancy_syntax(reader) && peek_delim(reader, ',')) {
+ return r_err(reader, SERD_ERR_BAD_SYNTAX,
+ "syntax does not support abbreviation\n");
+ }
+
while (!*ate_dot && eat_delim(reader, ',')) {
TRY_RET(read_object(reader, &ctx, true, ate_dot));
}
@@ -1602,6 +1607,10 @@ read_statement(SerdReader* reader)
reader->eof = true;
return reader->status <= SERD_FAILURE;
case '@':
+ if (!fancy_syntax(reader)) {
+ return r_err(reader, SERD_ERR_BAD_SYNTAX,
+ "syntax does not support directives\n");
+ }
TRY_RET(read_directive(reader));
read_ws_star(reader);
break;
@@ -1610,7 +1619,8 @@ read_statement(SerdReader* reader)
TRY_RET(read_wrappedGraph(reader, &ctx));
read_ws_star(reader);
} else {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "graph in Turtle\n");
+ return r_err(reader, SERD_ERR_BAD_SYNTAX,
+ "syntax does not support graphs\n");
}
break;
default:
@@ -1679,6 +1689,9 @@ read_nquadsDoc(SerdReader* reader)
if (peek_byte(reader) == '\0') {
reader->eof = true;
break;
+ } else if (peek_byte(reader) == '@') {
+ return r_err(reader, SERD_ERR_BAD_SYNTAX,
+ "syntax does not support directives\n");
}
// subject predicate object