From 53dbd6f360fcca3bac8d5f9f49a4980d3deef10e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 15 Aug 2020 22:06:37 +0200 Subject: Fix handling of bad syntax that ends a collection --- src/n3.c | 3 ++- tests/bad/bad-dot-in-collection.ttl | 1 + tests/bad/manifest.ttl | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/bad/bad-dot-in-collection.ttl diff --git a/src/n3.c b/src/n3.c index 906a0ac4..2e85ea66 100644 --- a/src/n3.c +++ b/src/n3.c @@ -1193,7 +1193,8 @@ end_collection(SerdReader* reader, ReadContext ctx, Ref n1, Ref n2, SerdStatus s pop_node(reader, n1); *ctx.flags &= ~(unsigned)SERD_LIST_CONT; if (!st) { - eat_byte_safe(reader, ')'); + return (eat_byte_check(reader, ')') == ')') ? SERD_SUCCESS + : SERD_ERR_BAD_SYNTAX; } return st; } diff --git a/tests/bad/bad-dot-in-collection.ttl b/tests/bad/bad-dot-in-collection.ttl new file mode 100644 index 00000000..d2d35bc2 --- /dev/null +++ b/tests/bad/bad-dot-in-collection.ttl @@ -0,0 +1 @@ +[ (1. diff --git a/tests/bad/manifest.ttl b/tests/bad/manifest.ttl index 2c103a84..e8ecb396 100644 --- a/tests/bad/manifest.ttl +++ b/tests/bad/manifest.ttl @@ -30,6 +30,7 @@ <#bad-char-in-uri> <#bad-datatype> <#bad-dot-after-subject> + <#bad-dot-in-collection> <#bad-eof-after-quotes> <#bad-eof-at-string-start> <#bad-eof-in-blank> @@ -193,6 +194,11 @@ mf:name "bad-dot-after-subject" ; mf:action . +<#bad-dot-in-collection> + rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "bad-dot-in-collection" ; + mf:action . + <#bad-eof-after-quotes> rdf:type rdft:TestTurtleNegativeSyntax ; mf:name "bad-eof-after-quotes" ; -- cgit v1.2.1