From b4fd19aae4647d4b226e90176b1c9f618dbe3294 Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Tue, 27 Sep 2016 14:45:19 +0200 Subject: [PATCH 1/2] add test exposing the problem --- tests/Composer/Test/Util/ProcessExecutorTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/Composer/Test/Util/ProcessExecutorTest.php b/tests/Composer/Test/Util/ProcessExecutorTest.php index 101b0b710..27fe00554 100644 --- a/tests/Composer/Test/Util/ProcessExecutorTest.php +++ b/tests/Composer/Test/Util/ProcessExecutorTest.php @@ -54,10 +54,16 @@ class ProcessExecutorTest extends TestCase { $process = new ProcessExecutor($buffer = new BufferIO('', StreamOutput::VERBOSITY_DEBUG)); $process->execute('echo https://foo:bar@example.org/ && echo http://foo@example.org && echo http://abcdef1234567890234578:x-oauth-token@github.com/', $output); - $this->assertEquals('Executing command (CWD): echo https://foo:***@example.org/ && echo http://foo@example.org && echo http://***:***@github.com/', trim($buffer->getOutput())); } + public function testDoesntHidePorts() + { + $process = new ProcessExecutor($buffer = new BufferIO('', StreamOutput::VERBOSITY_DEBUG)); + $process->execute('echo https://localhost:1234/', $output); + $this->assertEquals('Executing command (CWD): echo https://localhost:1234/', trim($buffer->getOutput())); + } + public function testSplitLines() { $process = new ProcessExecutor; From e60eff5f2e8cde36997f1cad29ef5910a7d17609 Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Tue, 27 Sep 2016 14:45:33 +0200 Subject: [PATCH 2/2] apply patch --- src/Composer/Util/ProcessExecutor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Util/ProcessExecutor.php b/src/Composer/Util/ProcessExecutor.php index ec1b9a3db..3969a188b 100644 --- a/src/Composer/Util/ProcessExecutor.php +++ b/src/Composer/Util/ProcessExecutor.php @@ -44,12 +44,12 @@ class ProcessExecutor public function execute($command, &$output = null, $cwd = null) { if ($this->io && $this->io->isDebug()) { - $safeCommand = preg_replace_callback('{(://)(?P[^:/\s]+):(?P[^@\s/]+)}i', function ($m) { + $safeCommand = preg_replace_callback('{://(?P[^:/\s]+):(?P[^@\s/]+)@}i', function ($m) { if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) { - return '://***:***'; + return '://***:***@'; } - return '://'.$m['user'].':***'; + return '://'.$m['user'].':***@'; }, $command); $this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand); }