From af14376c84780bbe43f33db24d6bc26282e5b965 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Wed, 30 Dec 2020 11:33:14 +0100 Subject: [PATCH] Scripting: Allow escaping quotes with \" Fixes #632 --- arm9/source/utils/scripting.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arm9/source/utils/scripting.c b/arm9/source/utils/scripting.c index 3293156..d94aaab 100644 --- a/arm9/source/utils/scripting.c +++ b/arm9/source/utils/scripting.c @@ -512,8 +512,9 @@ bool expand_arg(char* argex, const char* arg, u32 len) { u32 out_len = out - argex; if (out_len >= (_ARG_MAX_LEN-1)) return false; // maximum arglen reached - if (*in == '\\') { // escape line breaks + if (*in == '\\') { // escape line breaks & quotes if (*(++in) == 'n') *(out++) = '\n'; + else if (*in == '\"') *(out++) = '\"'; else { *(out++) = '\\'; *(out++) = *in; @@ -597,7 +598,7 @@ char* get_string(char* ptr, const char* line_end, u32* len, char** next, char* e // handle string if (*ptr == '\"') { // quotes str = ++ptr; - for (; (*ptr != '\"') && (ptr < line_end); ptr++, (*len)++); + for (; ((*ptr != '\"') || (*(ptr-1) == '\\')) && (ptr < line_end); ptr++, (*len)++); if (ptr >= line_end) { // failed if unresolved quotes if (err_str) snprintf(err_str, _ERR_STR_LEN, "unresolved quotes"); return NULL;