Explorar o código

BUG#259: ADD_TEST command generated in DartTestfile.txt now quotes/escapes all arguments.

Brad King %!s(int64=22) %!d(string=hai) anos
pai
achega
5f30c8caac
Modificáronse 1 ficheiros con 12 adicións e 7 borrados
  1. 12 7
      Source/cmAddTestCommand.cxx

+ 12 - 7
Source/cmAddTestCommand.cxx

@@ -67,18 +67,23 @@ void cmAddTestCommand::FinalPass()
     ++it;
     for (; it != m_Args.end(); ++it)
       {
-        if(it->find(" ") != std::string::npos) 
+      // Just double-quote all arguments so they are re-parsed
+      // correctly by the test system.
+      fout << " \"";
+      for(std::string::iterator c = it->begin(); c != it->end(); ++c)
+        {
+        // Escape quotes and backslashes within arguments.
+        if((*c == '"') || (*c == '\\'))
           {
-            fout << " \"" << *it << "\"";
-          }
-        else
-          {
-            fout << " " << *it;
+          fout << '\\';
           }
+        fout << *c;
+        }
+      fout << "\"";
       }
     fout << ")" << std::endl;
     fout.close();
-    }  
+    }
   return;
 }