20
20
#include < unordered_map>
21
21
#include < list>
22
22
#include < vector>
23
+ #include < algorithm>
23
24
#endif
24
25
25
26
@@ -36,8 +37,47 @@ typedef struct Variable_t Variables;
36
37
namespace modsecurity {
37
38
namespace transaction {
38
39
40
+
41
+ /*
42
+ * FIXME:
43
+ *
44
+ * This was an example grabbed from:
45
+ * http://stackoverflow.com/questions/8627698/case-insensitive-stl-containers-e-g-stdunordered-set
46
+ *
47
+ * We have to have a better hash function, maybe based on the std::hash.
48
+ *
49
+ */
50
+ struct MyEqual
51
+ {
52
+ bool operator ()(const std::string& Left, const std::string& Right) const
53
+ {
54
+ return Left.size () == Right.size ()
55
+ && std::equal ( Left.begin () , Left.end () , Right.begin (),
56
+ []( char a , char b )
57
+ {
58
+ return tolower (a) == tolower (b);
59
+ }
60
+ );
61
+ }
62
+ };
63
+
64
+ struct MyHash
65
+ {
66
+ size_t operator ()(const std::string& Keyval) const
67
+ {
68
+ // You might need a better hash function than this
69
+ size_t h = 0 ;
70
+ std::for_each ( Keyval.begin () , Keyval.end () , [&](char c )
71
+ {
72
+ h += tolower (c);
73
+ });
74
+ return h;
75
+ }
76
+ };
77
+
39
78
class Variables :
40
- public std::unordered_multimap<std::string, std::string> {
79
+ public std::unordered_multimap<std::string, std::string,
80
+ /* std::hash<std::string>*/ MyHash, MyEqual> {
41
81
public:
42
82
Variables ();
43
83
~Variables ();
@@ -59,6 +99,7 @@ class Variables :
59
99
std::vector<const transaction::Variable *> *l);
60
100
void resolveRegularExpression (const std::string& var,
61
101
std::vector<const transaction::Variable *> *l);
102
+
62
103
};
63
104
64
105
} // namespace transaction
0 commit comments