[mcs] Handle commas inside quotes correctly
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / Expression.cs
index ccfc0fa3a0ea8a46c1a5018af0732e84820892b4..ea302826b87e8d016b234b12937fcfeca96693e1 100644 (file)
@@ -464,6 +464,7 @@ namespace Microsoft.Build.BuildEngine {
                        List<string> args = new List<string> ();
                        int parens = 0;
                        bool backticks = false;
+                       bool inquotes = false;
                        int start = pos;
                        for (; pos < text.Length; ++pos) {
                                var ch = text [pos];
@@ -476,6 +477,11 @@ namespace Microsoft.Build.BuildEngine {
                                if (backticks)
                                        continue;
 
+                               if (ch == '\"') {
+                                       inquotes = !inquotes;
+                                       continue;
+                               }
+
                                if (ch == '(') {
                                        ++parens;
                                        continue;
@@ -498,7 +504,7 @@ namespace Microsoft.Build.BuildEngine {
                                if (parens != 0)
                                        continue;
 
-                               if (ch == ',') {
+                               if (ch == ',' && !inquotes) {
                                        args.Add (text.Substring (start, pos - start));
                                        start = pos + 1;
                                        continue;