diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-04-13 16:31:28 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-04-13 16:31:28 +0200 |
commit | 0bf34de43b2fc4c9c3104b986eaea5c5cc856b83 (patch) | |
tree | a68787051d9a77fa2ed694f4be50a33d1239ca8a /src/libutil/config.cc | |
parent | 1860070548db119fc5f958febff3a087f21d5c83 (diff) |
Validate Boolean settings better
Diffstat (limited to 'src/libutil/config.cc')
-rw-r--r-- | src/libutil/config.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libutil/config.cc b/src/libutil/config.cc index 2f9f98860..893cdccce 100644 --- a/src/libutil/config.cc +++ b/src/libutil/config.cc @@ -90,7 +90,12 @@ template<> std::string Setting<int>::to_string() template<> void Setting<bool>::set(const std::string & str) { - value = str == "true" || str == "1"; + if (str == "true" || str == "yes" || str == "1") + value = true; + else if (str == "false" || str == "no" || str == "0") + value = false; + else + throw UsageError("Boolean setting '%s' has invalid value '%s'", name, str); } template<> std::string Setting<bool>::to_string() |