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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/command_runner.dart

Issue 1156663002: Escape arguments in pub error message command line reproduction. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub.command_runner; 5 library pub.command_runner;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:args/args.dart'; 10 import 'package:args/args.dart';
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 // Explicitly exit on success to ensure that any dangling dart:io handles 124 // Explicitly exit on success to ensure that any dangling dart:io handles
125 // don't cause the process to never terminate. 125 // don't cause the process to never terminate.
126 await flushThenExit(exit_codes.SUCCESS); 126 await flushThenExit(exit_codes.SUCCESS);
127 } catch (error, chain) { 127 } catch (error, chain) {
128 log.exception(error, chain); 128 log.exception(error, chain);
129 129
130 if (options['trace']) { 130 if (options['trace']) {
131 log.dumpTranscript(); 131 log.dumpTranscript();
132 } else if (!isUserFacingException(error)) { 132 } else if (!isUserFacingException(error)) {
133 // TODO(23505): Implement proper shell escaping, not a partial hack.
134 protectArgument(String x) => x.contains(' ') ? '"$x"' : x;
nweiz 2015/05/22 20:01:34 Nit: don't type-annotate local variables, includin
133 log.error(""" 135 log.error("""
134 This is an unexpected error. Please run 136 This is an unexpected error. Please run
135 137
136 pub --trace ${options.arguments.map((arg) => "'$arg'").join(' ')} 138 pub --trace ${options.arguments.map(protectArgument).join(' ')}
137 139
138 and include the results in a bug report on http://dartbug.com/new. 140 and include the results in a bug report on http://dartbug.com/new.
139 """); 141 """);
140 } 142 }
141 143
142 await flushThenExit(_chooseExitCode(error)); 144 await flushThenExit(_chooseExitCode(error));
143 } 145 }
144 } 146 }
145 147
146 void printUsage() { 148 void printUsage() {
(...skipping 25 matching lines...) Expand all
172 Future _validatePlatform() async { 174 Future _validatePlatform() async {
173 if (Platform.operatingSystem != 'windows') return; 175 if (Platform.operatingSystem != 'windows') return;
174 176
175 var result = await runProcess('ver', []); 177 var result = await runProcess('ver', []);
176 if (result.stdout.join('\n').contains('XP')) { 178 if (result.stdout.join('\n').contains('XP')) {
177 log.error('Sorry, but pub is not supported on Windows XP.'); 179 log.error('Sorry, but pub is not supported on Windows XP.');
178 await flushThenExit(exit_codes.USAGE); 180 await flushThenExit(exit_codes.USAGE);
179 } 181 }
180 } 182 }
181 } 183 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698