diff options
-rw-r--r-- | .reuse/dep5 | 2 | ||||
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/n3.c | 12 | ||||
-rw-r--r-- | test/good/manifest.ttl | 7 | ||||
-rw-r--r-- | test/good/test-quote-escapes.nt | 52 | ||||
-rw-r--r-- | test/good/test-quote-escapes.ttl | 65 |
6 files changed, 136 insertions, 5 deletions
diff --git a/.reuse/dep5 b/.reuse/dep5 index 53511c48..d7d4151f 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -14,7 +14,7 @@ Comment: Extra tests for serd (potential contributions to the W3C suites) License: BSD-3-Clause OR ISC Files: AUTHORS NEWS serd.ttl -Copyright: 2011-2022 David Robillard <d@drobilla.net> +Copyright: 2011-2023 David Robillard <d@drobilla.net> Comment: Contributed to the Commons as a representation of simple facts License: 0BSD OR ISC @@ -9,6 +9,7 @@ serd (0.31.0) unstable; urgency=medium * Clean up code * Fix crash when trying to read chunks without starting * Fix hang when skipping an error at EOF when lax parsing + * Fix incorrect parsing of strange quote escape patterns * Gracefully handle bad characters in Turtle blank node syntax * Gracefully handle bad characters in Turtle datatype syntax * Improve serdi man page @@ -16,7 +17,7 @@ serd (0.31.0) unstable; urgency=medium * Replace duplicated dox_to_sphinx script with sphinxygen dependency * Test header for warnings more strictly - -- David Robillard <d@drobilla.net> Tue, 07 Feb 2023 23:34:12 +0000 + -- David Robillard <d@drobilla.net> Wed, 01 Mar 2023 00:36:43 +0000 serd (0.30.16) stable; urgency=medium @@ -361,9 +361,15 @@ read_STRING_LITERAL_LONG(SerdReader* const reader, skip_byte(reader, q3); break; } - *flags |= SERD_HAS_QUOTE; - push_byte(reader, ref, c); - st = read_character(reader, ref, flags, (uint8_t)q2); + + if (q2 == '\\') { + push_byte(reader, ref, c); + st = read_string_escape(reader, ref, flags); + } else { + *flags |= SERD_HAS_QUOTE; + push_byte(reader, ref, c); + st = read_character(reader, ref, flags, (uint8_t)q2); + } } else if (c == EOF) { return r_err(reader, SERD_ERR_BAD_SYNTAX, "end of file in long string\n"); } else { diff --git a/test/good/manifest.ttl b/test/good/manifest.ttl index 00009c4f..25359fdc 100644 --- a/test/good/manifest.ttl +++ b/test/good/manifest.ttl @@ -45,6 +45,7 @@ <#test-out-of-range-unicode> <#test-prefix> <#test-pretty> + <#test-quote-escapes> <#test-rel> <#test-semi-dot> <#test-uri-escape> @@ -281,6 +282,12 @@ mf:action <test-pretty.ttl> ; mf:result <test-pretty.nt> . +<#test-quote-escapes> + rdf:type rdft:TestTurtleEval ; + mf:name "test-quote-escapes" ; + mf:action <test-quote-escapes.ttl> ; + mf:result <test-quote-escapes.nt> . + <#test-rel> rdf:type rdft:TestTurtleEval ; mf:name "test-rel" ; diff --git a/test/good/test-quote-escapes.nt b/test/good/test-quote-escapes.nt new file mode 100644 index 00000000..26c06a8d --- /dev/null +++ b/test/good/test-quote-escapes.nt @@ -0,0 +1,52 @@ +<http://example.org/s> <http://example.org/p> "\"" . +<http://example.org/s> <http://example.org/p> "\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"" . +<http://example.org/s> <http://example.org/p> "\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"\"" . +<http://example.org/s> <http://example.org/p> "single \" within" . +<http://example.org/s> <http://example.org/p> "single \" within" . +<http://example.org/s> <http://example.org/p> "double \"\" within" . +<http://example.org/s> <http://example.org/p> "double \"\" within" . +<http://example.org/s> <http://example.org/p> "double \"\" within" . +<http://example.org/s> <http://example.org/p> "double \"\" within" . +<http://example.org/s> <http://example.org/p> "triple \"\"\" within" . +<http://example.org/s> <http://example.org/p> "triple \"\"\" within" . +<http://example.org/s> <http://example.org/p> "triple \"\"\" within" . +<http://example.org/s> <http://example.org/p> "triple \"\"\" within" . +<http://example.org/s> <http://example.org/p> "triple \"\"\" within" . +<http://example.org/s> <http://example.org/p> "triple \"\"\" within" . +<http://example.org/s> <http://example.org/p> "triple \"\"\" within" . +<http://example.org/s> <http://example.org/p> "\" start single" . +<http://example.org/s> <http://example.org/p> "\" start single" . +<http://example.org/s> <http://example.org/p> "\"\" start double" . +<http://example.org/s> <http://example.org/p> "\"\" start double" . +<http://example.org/s> <http://example.org/p> "\"\" start double" . +<http://example.org/s> <http://example.org/p> "\"\" start double" . +<http://example.org/s> <http://example.org/p> "\"\"\" start triple" . +<http://example.org/s> <http://example.org/p> "\"\"\" start triple" . +<http://example.org/s> <http://example.org/p> "\"\"\" start triple" . +<http://example.org/s> <http://example.org/p> "\"\"\" start triple" . +<http://example.org/s> <http://example.org/p> "\"\"\" start triple" . +<http://example.org/s> <http://example.org/p> "\"\"\" start triple" . +<http://example.org/s> <http://example.org/p> "\"\"\" start triple" . +<http://example.org/s> <http://example.org/p> "end single \"" . +<http://example.org/s> <http://example.org/p> "end double \"\"" . +<http://example.org/s> <http://example.org/p> "end double \"\"" . +<http://example.org/s> <http://example.org/p> "end triple \"\"\"" . +<http://example.org/s> <http://example.org/p> "end triple \"\"\"" . +<http://example.org/s> <http://example.org/p> "end triple \"\"\"" . +<http://example.org/s> <http://example.org/p> "end triple \"\"\"" . diff --git a/test/good/test-quote-escapes.ttl b/test/good/test-quote-escapes.ttl new file mode 100644 index 00000000..ffe14807 --- /dev/null +++ b/test/good/test-quote-escapes.ttl @@ -0,0 +1,65 @@ +<http://example.org/s> <http://example.org/p> "\"" . +<http://example.org/s> <http://example.org/p> "\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"" . +<http://example.org/s> <http://example.org/p> "\"\"\"\"" . + +<http://example.org/s> <http://example.org/p> """\"""" . + +<http://example.org/s> <http://example.org/p> """"\"""" . +<http://example.org/s> <http://example.org/p> """\"\"""" . + +<http://example.org/s> <http://example.org/p> """""\"""" . +<http://example.org/s> <http://example.org/p> """\""\"""" . +<http://example.org/s> <http://example.org/p> """\""\"""" . +<http://example.org/s> <http://example.org/p> """\"\"\"""" . +<http://example.org/s> <http://example.org/p> """"\"\"""" . + +<http://example.org/s> <http://example.org/p> """""\"\"""" . +<http://example.org/s> <http://example.org/p> """"\""\"""" . +<http://example.org/s> <http://example.org/p> """"\"\"\"""" . +<http://example.org/s> <http://example.org/p> """\"""\"""" . +<http://example.org/s> <http://example.org/p> """\""\"\"""" . +<http://example.org/s> <http://example.org/p> """\"\""\"""" . +<http://example.org/s> <http://example.org/p> """\"\"\"\"""" . + +<http://example.org/s> <http://example.org/p> """single " within""" . +<http://example.org/s> <http://example.org/p> """single \" within""" . + +<http://example.org/s> <http://example.org/p> """double "" within""" . +<http://example.org/s> <http://example.org/p> """double "\" within""" . +<http://example.org/s> <http://example.org/p> """double \"" within""" . +<http://example.org/s> <http://example.org/p> """double \"\" within""" . + +<http://example.org/s> <http://example.org/p> """triple ""\" within""" . +<http://example.org/s> <http://example.org/p> """triple "\"" within""" . +<http://example.org/s> <http://example.org/p> """triple "\"\" within""" . +<http://example.org/s> <http://example.org/p> """triple \""" within""" . +<http://example.org/s> <http://example.org/p> """triple \""\" within""" . +<http://example.org/s> <http://example.org/p> """triple \"\"" within""" . +<http://example.org/s> <http://example.org/p> """triple \"\"\" within""" . + +<http://example.org/s> <http://example.org/p> """" start single""" . +<http://example.org/s> <http://example.org/p> """\" start single""" . + +<http://example.org/s> <http://example.org/p> """"" start double""" . +<http://example.org/s> <http://example.org/p> """"\" start double""" . +<http://example.org/s> <http://example.org/p> """\"" start double""" . +<http://example.org/s> <http://example.org/p> """\"\" start double""" . + +<http://example.org/s> <http://example.org/p> """""\" start triple""" . +<http://example.org/s> <http://example.org/p> """"\"" start triple""" . +<http://example.org/s> <http://example.org/p> """"\"\" start triple""" . +<http://example.org/s> <http://example.org/p> """\""" start triple""" . +<http://example.org/s> <http://example.org/p> """\""\" start triple""" . +<http://example.org/s> <http://example.org/p> """\"\"" start triple""" . +<http://example.org/s> <http://example.org/p> """\"\"\" start triple""" . + +<http://example.org/s> <http://example.org/p> """end single \"""" . + +<http://example.org/s> <http://example.org/p> """end double "\"""" . +<http://example.org/s> <http://example.org/p> """end double \"\"""" . + +<http://example.org/s> <http://example.org/p> """end triple ""\"""" . +<http://example.org/s> <http://example.org/p> """end triple "\"\"""" . +<http://example.org/s> <http://example.org/p> """end triple \""\"""" . +<http://example.org/s> <http://example.org/p> """end triple \"\"\"""" . |