From 026c78df769bcbe104f73365aa9eada8108fb2f7 Mon Sep 17 00:00:00 2001 From: Angie Date: Sun, 9 Oct 2022 16:03:39 -0300 Subject: [PATCH] Escape `\` -> `\\` --- src/common/Utils.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/Utils.c b/src/common/Utils.c index 96a577b..7dd0262 100644 --- a/src/common/Utils.c +++ b/src/common/Utils.c @@ -31,6 +31,7 @@ size_t RabbitizerUtils_escapeString(char *dst, size_t dstSize, const char *src, size_t dstpos = 0; for (; srcPos < srcSize && dstpos < dstSize; srcPos++, src++) { + // The cases of this switch are sorted by ASCII order switch (*src) { case '\a': RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); @@ -62,6 +63,11 @@ size_t RabbitizerUtils_escapeString(char *dst, size_t dstSize, const char *src, RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '"'); break; + case '\\': + RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); + RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); + break; + default: RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, *src); break;