From: ShadowNinja Date: Thu, 15 Jan 2015 21:14:40 +0000 (-0500) Subject: Fix unescape_string removing all backslashes X-Git-Tag: 0.4.12~91 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=77e20a0c2188ab260e571a0406959113faa3e850;p=oweals%2Fminetest.git Fix unescape_string removing all backslashes --- diff --git a/src/util/string.h b/src/util/string.h index 3cb0f7bec..fa298bfaa 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -398,8 +398,7 @@ inline std::string wrap_rows(const std::string &from, /** - * Removes all backslashes from a string that had been escaped (FormSpec strings) - * + * Removes backslashes from an escaped string (FormSpec strings) */ template inline std::basic_string unescape_string(std::basic_string &s) @@ -407,8 +406,11 @@ inline std::basic_string unescape_string(std::basic_string &s) std::basic_string res; for (size_t i = 0; i < s.length(); i++) { - if (s[i] != '\\') - res += s[i]; + if (s[i] == '\\') + i++; + if (i >= s.length()) + break; + res += s[i]; } return res;