context safties

and from Marauder, hardened filename entry for con::evaluate/compileexec. if the string forwarded along is not a real filename, consider it an eval block
This commit is contained in:
AzaezelX 2026-03-02 11:38:20 -06:00
parent 19d8a5525d
commit 80f62573fe
8 changed files with 21 additions and 18 deletions

View file

@ -2496,14 +2496,15 @@ const char* GuiControl::evaluate( const char* str )
{
smThisControl = this;
StringTableEntry objectName = getName();
if (getName() == NULL)
objectName = getInternalName();
StringTableEntry fileName = getFilename();
if (fileName != NULL)
fileName = Platform::makeRelativePathName(fileName, NULL);
if (objectName != NULL)
objectName = getIdString();
String context = String::ToString("%s\nObject: %s", fileName, objectName);
const char* result = Con::evaluate(str, false, context).value;
StringTableEntry groupName = getGroup() ? getGroup()->getName() : NULL;
if (groupName != NULL)
groupName = getGroup()->getIdString();
String context = String::ToString("%s\nGroup: %s, Object: %s", getFilename(), groupName, objectName);
const char* result = Con::evaluate(str, false, context.c_str()).value;
smThisControl = NULL;
return result;