Browse Source

Report errors for invalid IRI characters and missing terminators.

git-svn-id: http://svn.drobilla.net/serd/trunk@478 490d8e77-9747-427b-9fa3-0b8f29cee8a0
zrythm_meson
David Robillard 8 years ago
parent
commit
25e6a68738
  1. 3
      NEWS
  2. 27
      src/reader.c

3
NEWS

@ -1,9 +1,10 @@ @@ -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;

27
src/reader.c

@ -17,6 +17,7 @@ @@ -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) @@ -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) @@ -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) @@ -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) @@ -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;
}

Loading…
Cancel
Save