Browse Source

ENH: Added check for invalid characters in output name.

Brad King 21 years ago
parent
commit
289429cd00
2 changed files with 20 additions and 0 deletions
  1. 10 0
      Source/cmAddCustomCommandCommand.cxx
  2. 10 0
      Source/cmAddCustomTargetCommand.cxx

+ 10 - 0
Source/cmAddCustomCommandCommand.cxx

@@ -171,6 +171,16 @@ bool cmAddCustomCommandCommand::InitialPass(std::vector<std::string> const& args
     return false;
     }
 
+  std::string::size_type pos = output.find_first_of("#<>");
+  if(pos != output.npos)
+    {
+    cmOStringStream msg;
+    msg << "called with OUTPUT containing a \"" << output[pos]
+        << "\".  This character is not allowed.";
+    this->SetError(msg.str().c_str());
+    return false;
+    }
+
   // Choose which mode of the command to use.
   if(source.empty() && output.empty())
     {

+ 10 - 0
Source/cmAddCustomTargetCommand.cxx

@@ -90,6 +90,16 @@ bool cmAddCustomTargetCommand::InitialPass(std::vector<std::string> const& args)
       }
     }
 
+  std::string::size_type pos = args[0].find_first_of("#<>");
+  if(pos != args[0].npos)
+    {
+    cmOStringStream msg;
+    msg << "called with target name containing a \"" << args[0][pos]
+        << "\".  This character is not allowed.";
+    this->SetError(msg.str().c_str());
+    return false;
+    }
+
   // Store the last command line finished.
   if(!currentLine.empty())
     {