Scripting: Bucket names can't start with .

This commit is contained in:
Vicki Pfau 2023-02-12 01:46:05 -08:00
parent 3139ac7d58
commit b1faf67438
1 changed files with 10 additions and 3 deletions

View File

@ -508,15 +508,22 @@ struct mScriptStorageBucket* mScriptStorageGetBucket(struct mScriptStorageContex
}
// Check if name is allowed
// Currently only names matching /[0-9A-Za-z_.]+/ are allowed
// Currently only names matching /[0-9A-Za-z][0-9A-Za-z_.]*/ are allowed
size_t i;
for (i = 0; name[i]; ++i) {
if (i >= STORAGE_LEN_MAX) {
return NULL;
}
if (!isalnum(name[i]) && name[i] != '_' && name[i] != '.') {
return NULL;
if (isalnum(name[i])) {
continue;
}
if (name[i] == '_') {
continue;
}
if (i > 0 && name[i] == '.') {
continue;
}
return NULL;
}
struct mScriptStorageBucket* bucket = HashTableLookup(&storage->buckets, name);
if (bucket) {