Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Unified Diff: runtime/bin/process_win.cc

Issue 9701061: Change quoting in Process implementation on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/src/io/ProcessCheckArgumentsScript.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_win.cc
diff --git a/runtime/bin/process_win.cc b/runtime/bin/process_win.cc
index 31c140cc20db5b9aa32b0fa5bbaf7a06bfe946c8..3cdd7893be08634bc8e49729dd89493960b978ad 100644
--- a/runtime/bin/process_win.cc
+++ b/runtime/bin/process_win.cc
@@ -575,12 +575,18 @@ int Process::Start(const char* path,
char* command_line = new char[command_line_length];
int len = 0;
int remaining = command_line_length;
- int written = snprintf(command_line + len, remaining, "\"%s\"", path);
+ // Quote the path if it contains a space.
+ char* format = strchr(path, ' ') != NULL ? "\"%s\"" : "%s";
Anton Muhin 2012/03/15 11:52:48 what if argument is already quoted, do we want to
Mads Ager (google) 2012/03/15 14:32:22 We don't care that the argument is already quoted.
+ int written = snprintf(command_line + len, remaining, format, path);
len += written;
remaining -= written;
ASSERT(remaining >= 0);
for (int i = 0; i < arguments_length; i++) {
- written = snprintf(command_line + len, remaining, " \"%s\"", arguments[i]);
+ // Quote the argument if it contains a space or a tab.
+ bool contains_tab_or_space = ((strchr(arguments[i], ' ') != NULL) ||
+ (strchr(arguments[i], '\t') != NULL));
Anton Muhin 2012/03/15 11:52:48 what about other whitespaces?
Mads Ager (google) 2012/03/15 14:32:22 In the command-line that you create the arguments
+ format = contains_tab_or_space ? " \"%s\"" : " %s";
+ written = snprintf(command_line + len, remaining, format, arguments[i]);
len += written;
remaining -= written;
ASSERT(remaining >= 0);
« no previous file with comments | « no previous file | tests/standalone/src/io/ProcessCheckArgumentsScript.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698