diff options
| author | 2022-01-18 14:26:38 +0000 | |
|---|---|---|
| committer | 2022-01-18 14:26:38 +0000 | |
| commit | 040bf53c77c67b8ccdb493ab711301fc649f53ab (patch) | |
| tree | e8d0342ff29116167cc5685c780c264681b9ab80 | |
| parent | Add constructors to the TokenList class. (diff) | |
Use C++11-style initialisation for the entity map in httpd_stats.
| -rw-r--r-- | src/modules/m_httpd_stats.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index f5e3b8427..74f0ef8aa 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -39,23 +39,13 @@ static ISupport::EventProvider* isevprov; namespace Stats { - struct Entities final - { - static const insp::flat_map<char, char const*>& entities; + static const insp::flat_map<char, char const*>& xmlentities = { + { '<', "lt" }, + { '>', "gt" }, + { '&', "amp" }, + { '"', "quot" }, }; - static const insp::flat_map<char, char const*>& init_entities() - { - static insp::flat_map<char, char const*> entities; - entities['<'] = "lt"; - entities['>'] = "gt"; - entities['&'] = "amp"; - entities['"'] = "quot"; - return entities; - } - - const insp::flat_map<char, char const*>& Entities::entities = init_entities(); - std::string Sanitize(const std::string& str) { std::string ret; @@ -63,8 +53,8 @@ namespace Stats for (const auto& chr : str) { - insp::flat_map<char, char const*>::const_iterator it = Entities::entities.find(chr); - if (it != Entities::entities.end()) + insp::flat_map<char, char const*>::const_iterator it = xmlentities.find(chr); + if (it != xmlentities.end()) { ret += '&'; ret += it->second; |
