Merge pull request #5093 from maiconpintoabreu/check-newname-category

[remx] Add check for category on new name
This commit is contained in:
Ray
2025-08-07 17:14:45 +02:00
committed by GitHub

View File

@@ -285,6 +285,20 @@ int main(int argc, char *argv[])
// Verify example exists in collection to be removed
char *exColInfo = LoadFileText(exCollectionFilePath);
if (TextFindIndex(exColInfo, argv[2]) != -1) // Example in the collection
{
// Security checks for new file name to verify category is included
int newCatIndex = TextFindIndex(argv[3], "_");
if (newCatIndex > 3)
{
char cat[12] = { 0 };
strncpy(cat, argv[3], newCatIndex);
bool newCatFound = false;
for (int i = 0; i < REXM_MAX_EXAMPLE_CATEGORIES; i++)
{
if (TextIsEqual(cat, exCategories[i])) { newCatFound = true; break; }
}
if (newCatFound)
{
strcpy(exName, argv[2]); // Register example name
strncpy(exCategory, exName, TextFindIndex(exName, "_"));
@@ -292,6 +306,10 @@ int main(int argc, char *argv[])
strncpy(exRecategory, exRename, TextFindIndex(exRename, "_"));
opCode = OP_RENAME;
}
else LOG("WARNING: Example new category is not valid\n");
}
else LOG("WARNING: Example new name does not include category\n");
}
else LOG("WARNING: RENAME: Example not available in the collection\n");
UnloadFileText(exColInfo);
}