-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected resolution of ${}
in metadata
#12577
Comments
This is horrible. Setting strings should not have any interpolation side effects. This "feature" shouldn't be documented, it should be ripped out as soon as possible. |
Perhaps worth noting that this seems to be used in legacy code: else if(id == NODEMETA_SIGN) // SignNodeMetadata
{
meta->setString("text", deSerializeString16(is));
//meta->setString("infotext","\"${text}\"");
meta->setString("infotext",
std::string("\"") + meta->getString("text") + "\"");
meta->setString("formspec","field[text;;${text}]");
return false;
} in
|
Oh god burn it with fire, I was looking over some of this compability code a while back and was wondering why all this code only applicable for world formats <23 (pre-0.4.0) should still be left in. Hopefully it has gone enough time that worlds have been converted to something slightly newer and the compat could be dropped (this would be compat for things that are over a decade now at this point). |
No it is not, this issue about
No they can't. You even quoted the code that resolves the references, a quick look should tell why this doesn't work. |
Yeah, I just realized and thus deleted my comment. |
@rubenwardy could we get a quick cdb search results page for the string |
CDB zipgrep doesn't work with special characters like that, it returns 0 results even when escaping with |
By the way, I described a workaround here: #12167 (comment) |
I suppose that a C++ method |
Minetest version
OS / Hardware
Operating system: Ubuntu 22.04 LTS
CPU: Intel® Core™ i5-4200U CPU @ 1.60GHz × 4
Summary
This may not be a bug, but it is confusing and undocumented. When getting data from metadata, if the value found is in the format
${K}
, then the value returned is the value of keyK
. There is a small recursion limit. This behavior could be a problem if you want to store arbitrary strings in metadata and one of the strings happens to be in the${}
format; you will get unexpected results.Here are two ways this behavior could be removed:
Metadata::getString
andMetadata::getStringToRef
from callingMetadata::resolveString
.recursion
parameter ofgetString
andgetStringToRef
to 2, so that the recursive resolution is only done when encountering the${}
syntax in formspecs.If this feature is removed, compatibility would be broken, in however minor a way.
Steps to reproduce
Run this code:
The text was updated successfully, but these errors were encountered: