summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-12-15 01:41:18 +0100
committerHaru <haru@dotalux.com>2016-11-20 18:10:46 +0100
commit985d4ead12a2007c34903e03dfc7411df1f847fd (patch)
treeea93a7d954bf829f240d4675df6c71c51931b4d6
parente384a7f2166026dc1c8cdfe49fc2fc105197ea02 (diff)
downloadhercules-985d4ead12a2007c34903e03dfc7411df1f847fd.tar.gz
hercules-985d4ead12a2007c34903e03dfc7411df1f847fd.tar.bz2
hercules-985d4ead12a2007c34903e03dfc7411df1f847fd.tar.xz
hercules-985d4ead12a2007c34903e03dfc7411df1f847fd.zip
Added validation for the AegisName while parsing the item db
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r--doc/item_db.txt4
-rw-r--r--src/map/itemdb.c24
2 files changed, 26 insertions, 2 deletions
diff --git a/doc/item_db.txt b/doc/item_db.txt
index ff434ef3c..6ffc8a52b 100644
--- a/doc/item_db.txt
+++ b/doc/item_db.txt
@@ -105,8 +105,8 @@ item_db: (
Id: Item id
-AegisName: Server name to reference the item in scripts and lookups,
- should use no spaces.
+AegisName: Server name to reference the item in scripts and lookups.
+ Allowed characters: [A-Za-z0-9_]
Name: Name in English for displaying as output for @ and script commands.
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 97f302b80..58397a2ee 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -1540,6 +1540,30 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) {
return 0;
}
+ {
+ const char *c = entry->name;
+ while (ISALNUM(*c) || *c == '_')
+ ++c;
+
+ if (*c != '\0') {
+ ShowWarning("itemdb_validate_entry: Invalid characters in the AegisName '%s' for item %d in '%s'. Skipping.\n",
+ entry->name, entry->nameid, source);
+ if (entry->script) {
+ script->free_code(entry->script);
+ entry->script = NULL;
+ }
+ if (entry->equip_script) {
+ script->free_code(entry->equip_script);
+ entry->equip_script = NULL;
+ }
+ if (entry->unequip_script) {
+ script->free_code(entry->unequip_script);
+ entry->unequip_script = NULL;
+ }
+ return 0;
+ }
+ }
+
if( entry->type < 0 || entry->type == IT_UNKNOWN || entry->type == IT_UNKNOWN2
|| (entry->type > IT_DELAYCONSUME && entry->type < IT_CASH ) || entry->type >= IT_MAX
) {