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 // 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; size_t i;
for (i = 0; name[i]; ++i) { for (i = 0; name[i]; ++i) {
if (i >= STORAGE_LEN_MAX) { if (i >= STORAGE_LEN_MAX) {
return NULL; return NULL;
} }
if (!isalnum(name[i]) && name[i] != '_' && name[i] != '.') { if (isalnum(name[i])) {
return NULL; continue;
} }
if (name[i] == '_') {
continue;
}
if (i > 0 && name[i] == '.') {
continue;
}
return NULL;
} }
struct mScriptStorageBucket* bucket = HashTableLookup(&storage->buckets, name); struct mScriptStorageBucket* bucket = HashTableLookup(&storage->buckets, name);
if (bucket) { if (bucket) {