aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-12-09 21:24:37 +0000
committerDavid Robillard <d@drobilla.net>2014-12-09 21:24:37 +0000
commit25e6a687388f217debc3b890a9334e21a0a523ac (patch)
tree8f092723112e77162c543c8c37cf6aec0bad58db /src
parentda50a4902ee92fafd34c2ea376da07381d3a221d (diff)
downloadserd-25e6a687388f217debc3b890a9334e21a0a523ac.tar.gz
serd-25e6a687388f217debc3b890a9334e21a0a523ac.tar.bz2
serd-25e6a687388f217debc3b890a9334e21a0a523ac.zip
Report errors for invalid IRI characters and missing terminators.
git-svn-id: http://svn.drobilla.net/serd/trunk@478 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src')
-rw-r--r--src/reader.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/reader.c b/src/reader.c
index c911f158..12d81fac 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -17,6 +17,7 @@
#include "serd_internal.h"
#include <assert.h>
+#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
@@ -802,6 +803,13 @@ read_IRIREF(SerdReader* reader)
break;
default:
if (c <= 0x20) {
+ if (isprint(c)) {
+ r_err(reader, SERD_ERR_BAD_SYNTAX,
+ "invalid IRI character `%c' (escape %%%02X)\n", c, c);
+ } else {
+ r_err(reader, SERD_ERR_BAD_SYNTAX,
+ "invalid IRI character (escape %%%02X)\n", c, c);
+ }
return pop_node(reader, ref);
} else {
push_byte(reader, ref, eat_byte_safe(reader, c));
@@ -1096,12 +1104,10 @@ read_blank(SerdReader* reader, ReadContext ctx, bool subject, Ref* dest)
}
*ctx.flags = old_flags;
}
- eat_byte_check(reader, ']');
- return true;
+ return (eat_byte_check(reader, ']') == ']');
case '(':
return read_collection(reader, ctx, dest);
- default:
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "invalid blank node\n");
+ default: return false; // never reached
}
}
@@ -1320,10 +1326,10 @@ read_triples(SerdReader* reader, ReadContext ctx, bool* ate_dot)
ctx.subject = subject;
if (nested) {
read_ws_star(reader);
+ ret = true;
if (peek_byte(reader) != '.') {
- read_predicateObjectList(reader, ctx, ate_dot);
+ ret = read_predicateObjectList(reader, ctx, ate_dot);
}
- ret = true;
} else {
TRY_RET(read_ws_plus(reader));
ret = read_predicateObjectList(reader, ctx, ate_dot);
@@ -1411,14 +1417,15 @@ read_statement(SerdReader* reader)
case '@':
TRY_RET(read_directive(reader));
read_ws_star(reader);
- return eat_byte_safe(reader, '.');
+ return (eat_byte_check(reader, '.') == '.');
default:
- TRY_RET(read_triples(reader, ctx, &ate_dot));
- if (ate_dot) {
+ if (!read_triples(reader, ctx, &ate_dot)) {
+ return false;
+ } else if (ate_dot) {
return true;
} else {
read_ws_star(reader);
- return eat_byte_check(reader, '.');
+ return (eat_byte_check(reader, '.') == '.');
}
break;
}