aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-03-08 15:43:40 -0500
committerDavid Robillard <d@drobilla.net>2018-03-08 15:43:59 -0500
commitf124a075ccc31285250872f93e9ff16ea865d4eb (patch)
tree2a0d6f7d3341782605674336b1a6e60b1bef63a2
parentb336b464087f5c2199999020ab810be9977f6d7c (diff)
downloadserd-f124a075ccc31285250872f93e9ff16ea865d4eb.tar.gz
serd-f124a075ccc31285250872f93e9ff16ea865d4eb.tar.bz2
serd-f124a075ccc31285250872f93e9ff16ea865d4eb.zip
Fix parsing local names that end with escaped dots
-rw-r--r--NEWS3
-rw-r--r--src/n3.c8
-rw-r--r--tests/good/test-local-name-ends-with-dot.ttl3
3 files changed, 10 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index c2191ab9..3126d8b2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,6 @@
serd (0.29.3) unstable;
+ * Fix parsing local names that end with escaped dots
* Add serdi option to write ASCII output
* Make serdi guess input syntax from extension if unspecified
* Make serdi syntax options case-insensitive
@@ -11,7 +12,7 @@ serd (0.29.3) unstable;
* Fix building with MSVC
* Clean up testing code
- -- David Robillard <d@drobilla.net> Sun, 24 Dec 2017 14:14:15 -0500
+ -- David Robillard <d@drobilla.net> Thu, 08 Mar 2018 15:42:51 -0500
serd (0.28.0) stable;
diff --git a/src/n3.c b/src/n3.c
index 0c78de1e..b35031bb 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -495,8 +495,9 @@ read_PLX(SerdReader* reader, Ref dest)
static SerdStatus
read_PN_LOCAL(SerdReader* reader, Ref dest, bool* ate_dot)
{
- uint8_t c = peek_byte(reader);
- SerdStatus st = SERD_SUCCESS;
+ uint8_t c = peek_byte(reader);
+ SerdStatus st = SERD_SUCCESS;
+ bool trailing_unescaped_dot = false;
switch (c) {
case '0': case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9': case ':': case '_':
@@ -518,10 +519,11 @@ read_PN_LOCAL(SerdReader* reader, Ref dest, bool* ate_dot)
} else if (st != SERD_SUCCESS && (st = read_PN_CHARS(reader, dest))) {
break;
}
+ trailing_unescaped_dot = (c == '.');
}
SerdNode* const n = deref(reader, dest);
- if (n->buf[n->n_bytes - 1] == '.') {
+ if (trailing_unescaped_dot) {
// Ate trailing dot, pop it from stack/node and inform caller
--n->n_bytes;
serd_stack_pop(&reader->stack, 1);
diff --git a/tests/good/test-local-name-ends-with-dot.ttl b/tests/good/test-local-name-ends-with-dot.ttl
new file mode 100644
index 00000000..e426876d
--- /dev/null
+++ b/tests/good/test-local-name-ends-with-dot.ttl
@@ -0,0 +1,3 @@
+@prefix eg: <http://example.org/> .
+
+eg:s eg:p eg:foo\. .