summaryrefslogtreecommitdiff
path: root/src/configparser.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-03-23 14:51:36 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-03-23 14:51:36 +0000
commit5a8d1f3298512a37e0b5e628da9113ba9bc8ab63 (patch)
tree2630943bf56f22f06ca46ca609f5bc7c7fc579b0 /src/configparser.cpp
parent0a331a3b64b2b531422bac0767e26dfcf56a0413 (diff)
Fail config parse if duplicate keys are found
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12658 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r--src/configparser.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp
index 6b1b47e6d..2e84b1736 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -84,7 +84,7 @@ struct Parser
unget(ch);
}
- bool kv(std::vector<KeyVal>* items)
+ bool kv(std::vector<KeyVal>* items, std::set<std::string>& seen)
{
std::string key;
nextword(key);
@@ -149,6 +149,10 @@ struct Parser
else
value.push_back(ch);
}
+
+ if (!seen.insert(key).second)
+ throw CoreException("Duplicate key '" + key + "' found");
+
items->push_back(KeyVal(key, value));
return true;
}
@@ -169,9 +173,10 @@ struct Parser
throw CoreException("Empty tag name");
std::vector<KeyVal>* items;
+ std::set<std::string> seen;
tag = ConfigTag::create(name, current.filename, current.line, items);
- while (kv(items));
+ while (kv(items, seen));
if (name == "include")
{