From bcfcafd2adfa2cabd1c823ef026aaaa79a7fb73c Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 8 Dec 2023 12:44:48 +0100 Subject: [PATCH] Backport serd double backslash encoding fix Signed-off-by: falkTX --- source/modules/lilv/serd-0.24.0/src/reader.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/source/modules/lilv/serd-0.24.0/src/reader.c b/source/modules/lilv/serd-0.24.0/src/reader.c index fad845a04..6adef5d50 100644 --- a/source/modules/lilv/serd-0.24.0/src/reader.c +++ b/source/modules/lilv/serd-0.24.0/src/reader.c @@ -554,9 +554,19 @@ read_STRING_LITERAL_LONG(SerdReader* reader, SerdNodeFlags* flags, uint8_t q) eat_byte_safe(reader, q3); return ref; } else { - *flags |= SERD_HAS_QUOTE; - push_byte(reader, ref, c); - read_character(reader, ref, flags, q2); + if (q2 == '\\') { + push_byte(reader, ref, c); + if (!read_ECHAR(reader, ref, flags) && + !read_UCHAR(reader, ref, &code)) { + r_err(reader, SERD_ERR_BAD_SYNTAX, + "invalid escape `\\%c'\n", peek_byte(reader)); + return pop_node(reader, ref); + } + } else { + *flags |= SERD_HAS_QUOTE; + push_byte(reader, ref, c); + read_character(reader, ref, flags, q2); + } } } else { read_character(reader, ref, flags, eat_byte_safe(reader, c));