diff options
| author | 2020-02-20 18:02:51 +0000 | |
|---|---|---|
| committer | 2020-02-20 18:02:51 +0000 | |
| commit | 82c89d40cc6cd0100b4c68e72f869ff007f4ef36 (patch) | |
| tree | 051fabbee8902adcbb334c7c553278cfd7afcb96 /src/configparser.cpp | |
| parent | Fix a memory leak in the httpd module when sockets are closed late. (diff) | |
Add support for using environment variables in the config.
Diffstat (limited to 'src/configparser.cpp')
| -rw-r--r-- | src/configparser.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp index 0102c910c..6fdc56c32 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -205,7 +205,7 @@ struct Parser while (1) { ch = next(); - if (isalnum(ch) || (varname.empty() && ch == '#')) + if (isalnum(ch) || (varname.empty() && ch == '#') || ch == '.') varname.push_back(ch); else if (ch == ';') break; @@ -233,6 +233,13 @@ struct Parser throw CoreException("Invalid numeric character reference '&" + varname + ";'"); value.push_back(static_cast<char>(lvalue)); } + else if (varname.compare(0, 4, "env.") == 0) + { + const char* envstr = getenv(varname.c_str() + 4); + if (!envstr) + throw CoreException("Undefined XML environment entity reference '&" + varname + ";'"); + value.append(envstr); + } else { insp::flat_map<std::string, std::string>::iterator var = stack.vars.find(varname); |
