From 4011a0d7480ac122fe71e2497ff67faaa8c95d30 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 5 Sep 2023 20:18:43 +0800 Subject: [PATCH] Fix double quotes escape (#1397 #1435 #1946 #1990) (#2002) --- src/libslic3r/Config.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 629d8778d5..8522d59657 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -43,7 +43,7 @@ namespace Slic3r { //static const std::string CONFIG_INHERITS_KEY = "inherits"; //static const std::string CONFIG_INSTANT_KEY = "instantiation"; -// Escape \n, \r and backslash +// Escape double quotes, \n, \r and backslash std::string escape_string_cstyle(const std::string &str) { // Allocate a buffer twice the input string length, @@ -58,9 +58,9 @@ std::string escape_string_cstyle(const std::string &str) } else if (c == '\n') { (*outptr ++) = '\\'; (*outptr ++) = 'n'; - } else if (c == '\\') { - (*outptr ++) = '\\'; - (*outptr ++) = '\\'; + } else if (c == '\\' || c == '"') { + (*outptr++) = '\\'; + (*outptr++) = c; } else (*outptr ++) = c; } @@ -117,7 +117,7 @@ std::string escape_strings_cstyle(const std::vector &strs) return std::string(out.data(), outptr - out.data()); } -// Unescape \n, \r and backslash +// Unescape double quotes, \n, \r and backslash bool unescape_string_cstyle(const std::string &str, std::string &str_out) { std::vector out(str.size(), 0);