mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
Use C++11-style initialisation for the entity map in httpd_stats.
This commit is contained in:
parent
4856a8f967
commit
040bf53c77
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user