aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/n3.c9
-rw-r--r--tests/bad/bad-null-byte.ttlbin0 -> 27 bytes
-rw-r--r--tests/bad/manifest.ttl6
3 files changed, 12 insertions, 3 deletions
diff --git a/src/n3.c b/src/n3.c
index fad12070..906a0ac4 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -1063,7 +1063,7 @@ read_object(SerdReader* reader, ReadContext* ctx, bool emit, bool* ate_dot)
}
}
switch (c) {
- case EOF: case '\0': case ')':
+ case EOF: case ')':
return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected object\n");
case '[':
simple = false;
@@ -1166,7 +1166,7 @@ read_predicateObjectList(SerdReader* reader, ReadContext ctx, bool* ate_dot)
do {
read_ws_star(reader);
switch (c = peek_byte(reader)) {
- case EOF: case '\0':
+ case EOF:
return r_err(reader, SERD_ERR_BAD_SYNTAX,
"unexpected end of file\n");
case '.': case ']': case '}':
@@ -1471,7 +1471,10 @@ read_n3_statement(SerdReader* reader)
SerdStatus st = SERD_SUCCESS;
read_ws_star(reader);
switch (peek_byte(reader)) {
- case EOF: case '\0':
+ case '\0':
+ eat_byte_safe(reader, '\0');
+ return SERD_FAILURE;
+ case EOF:
return SERD_FAILURE;
case '@':
if (!fancy_syntax(reader)) {
diff --git a/tests/bad/bad-null-byte.ttl b/tests/bad/bad-null-byte.ttl
new file mode 100644
index 00000000..4f2cb404
--- /dev/null
+++ b/tests/bad/bad-null-byte.ttl
Binary files differ
diff --git a/tests/bad/manifest.ttl b/tests/bad/manifest.ttl
index 57fb02f7..2c103a84 100644
--- a/tests/bad/manifest.ttl
+++ b/tests/bad/manifest.ttl
@@ -59,6 +59,7 @@
<#bad-misspelled-prefix>
<#bad-namespace>
<#bad-ns>
+ <#bad-null-byte>
<#bad-num>
<#bad-object2>
<#bad-object>
@@ -337,6 +338,11 @@
mf:name "bad-ns" ;
mf:action <bad-ns.ttl> .
+<#bad-null-byte>
+ rdf:type rdft:TestTurtleNegativeSyntax ;
+ mf:name "bad-null-byte" ;
+ mf:action <bad-null-byte.ttl> .
+
<#bad-num>
rdf:type rdft:TestTurtleNegativeSyntax ;
mf:name "bad-num" ;