From 142d43b3fb9ab8970bc208deedddb38397fb515d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= <gustaf@hanicef.me> Date: Sat, 18 Nov 2023 15:02:58 +0100 Subject: [PATCH] Remove single quotes and limit escape to quotes --- src/command.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/command.c b/src/command.c index 2c82cd7aba..88326814c2 100644 --- a/src/command.c +++ b/src/command.c @@ -221,7 +221,6 @@ void COM_BufExecute(void) char *ptext; char line[1024] = ""; INT32 quotes; - char qc = 0; while (com_text.cursize) { @@ -231,13 +230,10 @@ void COM_BufExecute(void) quotes = 0; for (i = 0; i < com_text.cursize; i++) { - if ((ptext[i] == '\"' || ptext[i] == '\'') && !quotes && i > 0 && ptext[i-1] != ' ') // Malformed command + if (ptext[i] == '\"' && !quotes && i > 0 && ptext[i-1] != ' ') // Malformed command break; - if (((quotes & 1) ? (ptext[i] == qc) : (ptext[i] == '\"' || ptext[i] == '\'')) && (i == 0 || ptext[i-1] != '\\')) - { + if (ptext[i] == '\"' && (i == 0 || ptext[i-1] != '\\')) quotes++; - qc = ptext[i]; - } if (!(quotes & 1) && ptext[i] == ';') break; // don't break if inside a quoted string if (ptext[i] == '\n' || ptext[i] == '\r') @@ -2574,19 +2570,18 @@ skipwhite: } // handle quoted strings specially - if (c == '\"' || c == '\'') + if (c == '\"') { - char qc = c; data++; for (;;) { c = *data++; - if (c == qc || c == '\0') + if (c == '\"' || c == '\0') { com_token[len] = 0; return data; } - if (c == '\\' && *data != '\0') + if (c == '\\' && *data == '\"') c = *data++; // parse next token literally if (c == '\033') data++; -- GitLab