aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-06-09 18:21:21 -0400
committerDavid Robillard <d@drobilla.net>2024-06-09 18:21:56 -0400
commitc57e92c6eeb715f0caa6c4799a7a1e54e49fc62f (patch)
treedd1fd991014e72595378d524e4921a808e74a0d5
parent8f94d1b38df369c9316b499bf9434cf89c825098 (diff)
downloadserd-c57e92c6eeb715f0caa6c4799a7a1e54e49fc62f.tar.gz
serd-c57e92c6eeb715f0caa6c4799a7a1e54e49fc62f.tar.bz2
serd-c57e92c6eeb715f0caa6c4799a7a1e54e49fc62f.zip
Treat out of range unicode characters as errors
-rw-r--r--NEWS3
-rw-r--r--src/n3.c4
-rw-r--r--test/extra/bad/manifest.ttl1
-rw-r--r--test/extra/good/manifest.ttl7
-rw-r--r--test/extra/lax/manifest.ttl7
-rw-r--r--test/extra/lax/test-out-of-range-unicode.nt (renamed from test/extra/good/test-out-of-range-unicode.nt)0
-rw-r--r--test/extra/lax/test-out-of-range-unicode.ttl (renamed from test/extra/good/test-out-of-range-unicode.ttl)0
7 files changed, 12 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index fc35155c..f051f9ee 100644
--- a/NEWS
+++ b/NEWS
@@ -4,8 +4,9 @@ serd (0.32.3) unstable; urgency=medium
* Fix library current_version on MacOS
* Fix parsing NQuads lines with no space before the final dot
* Support reading lone lists in lax mode
+ * Treat out of range unicode characters as errors
- -- David Robillard <d@drobilla.net> Fri, 29 Mar 2024 13:36:36 +0000
+ -- David Robillard <d@drobilla.net> Sun, 09 Jun 2024 22:15:14 +0000
serd (0.32.2) stable; urgency=medium
diff --git a/src/n3.c b/src/n3.c
index 6684fae8..39b00d13 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -97,7 +97,7 @@ read_UCHAR(SerdReader* const reader, const Ref dest, uint32_t* const char_code)
code);
push_bytes(reader, dest, replacement_char, 3);
*char_code = 0xFFFD;
- return SERD_SUCCESS;
+ return reader->strict ? SERD_ERR_BAD_SYNTAX : SERD_SUCCESS;
}
// Build output in buf
@@ -325,7 +325,7 @@ read_string_escape(SerdReader* const reader,
uint32_t code = 0;
if ((st = read_ECHAR(reader, ref, flags)) &&
(st = read_UCHAR(reader, ref, &code))) {
- return r_err(reader, st, "invalid escape '\\%c'\n", peek_byte(reader));
+ return r_err(reader, st, "expected string escape sequence\n");
}
return st;
diff --git a/test/extra/bad/manifest.ttl b/test/extra/bad/manifest.ttl
index 7e35e5ff..dfb84ce9 100644
--- a/test/extra/bad/manifest.ttl
+++ b/test/extra/bad/manifest.ttl
@@ -13,6 +13,7 @@
<#bad-blank-node-label>
<#bad-blank-predicate>
<#bad-blank-syntax>
+ <#bad-blank-syntax>
<#bad-bom>
<#bad-char-in-local>
<#bad-char-in-prefix>
diff --git a/test/extra/good/manifest.ttl b/test/extra/good/manifest.ttl
index 3b911990..c464d700 100644
--- a/test/extra/good/manifest.ttl
+++ b/test/extra/good/manifest.ttl
@@ -48,7 +48,6 @@
<#test-nt-syntax-eol-crlf>
<#test-nt-syntax-eol-lf>
<#test-nt-syntax-eol-lfcr>
- <#test-out-of-range-unicode>
<#test-prefix>
<#test-quote-escapes>
<#test-rel>
@@ -295,12 +294,6 @@
mf:action <test-nt-syntax-eol-lfcr.nt> ;
mf:name "test-nt-syntax-eol-lfcr" .
-<#test-out-of-range-unicode>
- a rdft:TestTurtleEval ;
- mf:action <test-out-of-range-unicode.ttl> ;
- mf:name "test-out-of-range-unicode" ;
- mf:result <test-out-of-range-unicode.nt> .
-
<#test-prefix>
a rdft:TestTurtleEval ;
mf:action <test-prefix.ttl> ;
diff --git a/test/extra/lax/manifest.ttl b/test/extra/lax/manifest.ttl
index bf51f931..f79e1984 100644
--- a/test/extra/lax/manifest.ttl
+++ b/test/extra/lax/manifest.ttl
@@ -19,6 +19,7 @@
<#test-bad-utf8-ttl>
<#test-bad-utf8-trig>
<#test-lone-list>
+ <#test-out-of-range-unicode>
) .
<#test-bad-string-nq>
@@ -98,3 +99,9 @@
mf:action <test-lone-list.ttl> ;
mf:name "test-lone-list" ;
mf:result <test-lone-list.nt> .
+
+<#test-out-of-range-unicode>
+ a rdft:TestTurtleNegativeSyntax ;
+ mf:action <test-out-of-range-unicode.ttl> ;
+ mf:name "test-out-of-range-unicode" ;
+ mf:result <test-out-of-range-unicode.nt> .
diff --git a/test/extra/good/test-out-of-range-unicode.nt b/test/extra/lax/test-out-of-range-unicode.nt
index 5def9e31..5def9e31 100644
--- a/test/extra/good/test-out-of-range-unicode.nt
+++ b/test/extra/lax/test-out-of-range-unicode.nt
diff --git a/test/extra/good/test-out-of-range-unicode.ttl b/test/extra/lax/test-out-of-range-unicode.ttl
index 7e64785a..7e64785a 100644
--- a/test/extra/good/test-out-of-range-unicode.ttl
+++ b/test/extra/lax/test-out-of-range-unicode.ttl