diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-07 17:46:47 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-07 17:46:47 -0500 |
commit | 94fa461e0fe0c8004ee062c4d198dcae0bd29d68 (patch) | |
tree | 38616d7e75addfd82c8a5adbe40926e852f7821a | |
parent | bca63af9342506d7d6a9cc0e639a18a2613649ae (diff) | |
download | horizon-94fa461e0fe0c8004ee062c4d198dcae0bd29d68.tar.gz horizon-94fa461e0fe0c8004ee062c4d198dcae0bd29d68.tar.bz2 horizon-94fa461e0fe0c8004ee062c4d198dcae0bd29d68.tar.xz horizon-94fa461e0fe0c8004ee062c4d198dcae0bd29d68.zip |
hscript: Lowercase the key, and don't parse an invalid key further
-rw-r--r-- | hscript/script.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/hscript/script.cc b/hscript/script.cc index 40c5fbf..01c920d 100644 --- a/hscript/script.cc +++ b/hscript/script.cc @@ -10,6 +10,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +#include <algorithm> #include <fstream> #include <iostream> #include "script.hh" @@ -104,6 +105,9 @@ const Script *Script::load(std::istream &sstream, ScriptOptions opts) { PARSER_ERROR("key '" + key + "' has no value") } + /* Normalise key to lower-case */ + std::transform(key.begin(), key.end(), key.begin(), ::tolower); + if(!is_key(key)) { /* Invalid key */ if(opts.test(StrictMode)) { @@ -111,6 +115,7 @@ const Script *Script::load(std::istream &sstream, ScriptOptions opts) { } else { PARSER_WARNING("key '" + key + "' is not defined") } + continue; } } |