Use C++11-style initialisation for the entity map in httpd_stats.

This commit is contained in:
Sadie Powell 2022-01-18 14:26:38 +00:00
parent 4856a8f967
commit 040bf53c77

View File

@ -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;