]> granicus.if.org Git - icinga2/commitdiff
Move object name validation into ConfigItemBuilder class
authorGunnar Beutner <gunnar@beutner.name>
Sat, 15 Aug 2015 07:40:42 +0000 (09:40 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Sat, 15 Aug 2015 18:07:11 +0000 (20:07 +0200)
fixes #9911

lib/config/configitembuilder.cpp
lib/config/vmops.hpp

index 02f244660c672d9466749b62be9451dbc8884028..439573c79c51c02b89a5fe5ad2e37c3ae955b28a 100644 (file)
@@ -89,6 +89,12 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
                BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
        }
 
+       if (m_Name.FindFirstOf("!") != String::NPos) {
+               std::ostringstream msgbuf;
+               msgbuf << "Name for object '" << m_Name << "' of type '" << m_Type << "' is invalid: Object names may not contain '!'";
+               BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), m_DebugInfo));
+       }
+
        std::vector<Expression *> exprs;
 
        Array::Ptr templateArray = new Array();
index e7827492ff47883765d782efea40d62d744b618f..5f9d7c6053b2e781daa13697cf285450f925a913 100644 (file)
@@ -141,13 +141,6 @@ public:
                }
 
                item->SetType(type);
-
-               if (name.FindFirstOf("!") != String::NPos) {
-                       std::ostringstream msgbuf;
-                       msgbuf << "Name for object '" << name << "' of type '" << type << "' is invalid: Object names may not contain '!'";
-                       BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debugInfo));
-               }
-
                item->SetName(name);
 
                item->AddExpression(new OwnedExpression(expression));