aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-01-15 16:14:40 -0500
committerShadowNinja <shadowninja@minetest.net>2015-01-15 16:16:41 -0500
commit77e20a0c2188ab260e571a0406959113faa3e850 (patch)
treed34b7b361f82fefb37a865ecdb639198467e348d
parentc9669e90bbf07e4975671113a8edeaee3f55cb4c (diff)
downloadminetest-77e20a0c2188ab260e571a0406959113faa3e850.tar.gz
minetest-77e20a0c2188ab260e571a0406959113faa3e850.tar.bz2
minetest-77e20a0c2188ab260e571a0406959113faa3e850.zip
Fix unescape_string removing all backslashes
-rw-r--r--src/util/string.h10
1 files changed, 6 insertions, 4 deletions
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 <typename T>
inline std::basic_string<T> unescape_string(std::basic_string<T> &s)
@@ -407,8 +406,11 @@ inline std::basic_string<T> unescape_string(std::basic_string<T> &s)
std::basic_string<T> 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;