diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/metadata.cpp | 11 | ||||
-rw-r--r-- | src/metadata.h | 2 | ||||
-rw-r--r-- | src/util/string.h | 1 |
3 files changed, 10 insertions, 4 deletions
diff --git a/src/metadata.cpp b/src/metadata.cpp index d8a41218d..f02495fa4 100644 --- a/src/metadata.cpp +++ b/src/metadata.cpp @@ -51,7 +51,7 @@ const std::string &IMetadata::getString(const std::string &name, std::string *pl return empty_string; } - return resolveString(*raw, place, recursion); + return resolveString(*raw, place, recursion, true); } bool IMetadata::getStringToRef(const std::string &name, @@ -61,16 +61,21 @@ bool IMetadata::getStringToRef(const std::string &name, if (!raw) return false; - const std::string &resolved = resolveString(*raw, &str, recursion); + const std::string &resolved = resolveString(*raw, &str, recursion, true); if (&resolved != &str) str = resolved; return true; } const std::string &IMetadata::resolveString(const std::string &str, std::string *place, - u16 recursion) const + u16 recursion, bool deprecated) const { if (recursion <= 1 && str.substr(0, 2) == "${" && str[str.length() - 1] == '}') { + if (deprecated) { + warningstream << "Deprecated use of recursive resolution syntax in metadata: "; + safe_print_string(warningstream, str); + warningstream << std::endl; + } // It may be the case that &str == place, but that's fine. return getString(str.substr(2, str.length() - 3), place, recursion + 1); } diff --git a/src/metadata.h b/src/metadata.h index 45a3774d2..1a0350bbf 100644 --- a/src/metadata.h +++ b/src/metadata.h @@ -65,7 +65,7 @@ public: // Add support for variable names in values. Uses place like getString. const std::string &resolveString(const std::string &str, std::string *place, - u16 recursion = 0) const; + u16 recursion = 0, bool deprecated = false) const; protected: // Returns nullptr to indicate absence of value. Uses place like getString. diff --git a/src/util/string.h b/src/util/string.h index 80eea754c..4c7a4068d 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -459,6 +459,7 @@ inline void str_formspec_escape(std::string &str) str_replace(str, "[", "\\["); str_replace(str, ";", "\\;"); str_replace(str, ",", "\\,"); + str_replace(str, "$", "\\$"); } /** |