From 1d332bf960503e8d4164c668b99c863b2ed76a49 Mon Sep 17 00:00:00 2001 From: Michael Votaw Date: Fri, 23 Feb 2024 19:21:24 -0600 Subject: [PATCH] Modified MsdFile::ReadBuf() so that escaped characters are still skipped when bUnescape == false As of this commit, this won't affect anything except CourseLoaderCRS, because everywhere else is passing `true` for the bUnescape parameter. --- src/MsdFile.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/MsdFile.cpp b/src/MsdFile.cpp index 7c52a95625..e3abed318e 100644 --- a/src/MsdFile.cpp +++ b/src/MsdFile.cpp @@ -127,8 +127,24 @@ void MsdFile::ReadBuf( const char *buf, int len, bool bUnescape ) /* We've gone through all the control characters. All that is left is either an escaped character, * ie \#, \\, \:, etc., or a regular character. */ - if( bUnescape && i < len && buf[i] == '\\' ) - ++i; + if(buf[i] == '\\' && i < len) + { + // If we're escaping the next character, skip the '\\' + if(bUnescape) + { + ++i; + } + // Otherwise, add the '\\' to cProcessed here, so that + // whatever character is coming next stays escaped in + // the resulting value/parameter string + // (and most importantly, it doesn't get parsed as a control character) + // on the next iteration + else + { + cProcessed[iProcessedLen++] = buf[i++]; + } + } + if( i < len ) { cProcessed[iProcessedLen++] = buf[i++];