aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--src/reader.c27
2 files changed, 19 insertions, 11 deletions
diff --git a/NEWS b/NEWS
index d27ee334..75d7f483 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,10 @@
serd (0.21.0) unstable;
* Remove dependence on fmax() to avoid portability issues
+ * Report errors for invalid IRI characters and missing terminators
* Fix warnings when building with ISO C++ compilers
- -- David Robillard <d@drobilla.net> Fri, 21 Nov 2014 20:40:06 -0500
+ -- David Robillard <d@drobilla.net> Tue, 09 Dec 2014 16:24:15 -0500
serd (0.20.0) stable;
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;
}