From b1faf674388d69db64e10045cd0c57d50ecdc1f8 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 12 Feb 2023 01:46:05 -0800 Subject: [PATCH] Scripting: Bucket names can't start with . --- src/script/storage.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/script/storage.c b/src/script/storage.c index f17da67de..b1b740162 100644 --- a/src/script/storage.c +++ b/src/script/storage.c @@ -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) {