]> granicus.if.org Git - icinga2/commitdiff
Fix: ConfigItem types and names are not case-insensitive
authorGunnar Beutner <gunnar.beutner@netways.de>
Wed, 8 May 2013 08:46:50 +0000 (10:46 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Wed, 8 May 2013 08:46:50 +0000 (10:46 +0200)
Fixes #4044

lib/base/qstring.h
lib/config/configcompilercontext.h
lib/config/configitem.h

index e085045c355e3c3a6958b1b47527f5b32aa180b2..395f56c8f1c2942fe477a468cd63620d12277519 100644 (file)
@@ -24,6 +24,7 @@
 #include <boost/range/iterator.hpp>
 #include <ostream>
 #include <istream>
+#include <utility>
 
 namespace icinga {
 
@@ -155,6 +156,20 @@ struct string_iless : std::binary_function<String, String, bool>
        }
 };
 
+struct pair_string_iless : std::binary_function<std::pair<String, String>, std::pair<String, String>, bool>
+{
+       bool operator()(const std::pair<String, String>& p1, const std::pair<String, String>& p2) const
+       {
+               if (string_iless()(p1.first, p2.first))
+                       return true;
+
+               if (string_iless()(p2.first, p1.first))
+                       return false;
+
+               return string_iless()(p1.second, p2.second);
+       }
+};
+
 }
 
 namespace boost
index f34966eeb119f3dd003f781e54c69d97cb2f5082..8852bcf943dbf4a353f0b4599bce690719d56506 100644 (file)
@@ -82,9 +82,9 @@ private:
         int m_Flags;
 
        std::vector<ConfigItem::Ptr> m_Items;
-        std::map<std::pair<String, String>, ConfigItem::Ptr> m_ItemsMap;
+        std::map<std::pair<String, String>, ConfigItem::Ptr, pair_string_iless> m_ItemsMap;
 
-        std::map<String, shared_ptr<ConfigType> > m_Types;
+        std::map<String, shared_ptr<ConfigType>, string_iless> m_Types;
 
         std::vector<ConfigCompilerError> m_Errors;
 
index f91aef1084742036da621b54a727cadbaefaf6f6..8b9e8a2622fe04575a8d2f2ec496931b5338a473 100644 (file)
@@ -99,7 +99,7 @@ private:
 
        static boost::mutex m_Mutex;
 
-       typedef std::map<std::pair<String, String>, ConfigItem::Ptr> ItemMap;
+       typedef std::map<std::pair<String, String>, ConfigItem::Ptr, pair_string_iless> ItemMap;
        static ItemMap m_Items; /**< All registered configuration items. */
 
        static ConfigItem::Ptr GetObjectUnlocked(const String& type,