Escape \ -> \\

This commit is contained in:
Angie 2022-10-09 16:03:39 -03:00
parent 9bf973e82d
commit 026c78df76

View File

@ -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;