From 278f0ec3504d4a85af3ba3939cd4a0989db4055c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 8 Apr 2012 22:17:15 +0200 Subject: [PATCH] Fix git config parsing, fixes #525 --- src/Composer/Command/InitCommand.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index cab7d5749..e72f01e73 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -323,11 +323,16 @@ EOT $finder = new ExecutableFinder(); $gitBin = $finder->find('git'); - $cmd = new Process(sprintf('%s config -l', $gitBin)); + $cmd = new Process(sprintf('%s config -l', escapeshellarg($gitBin))); $cmd->run(); if ($cmd->isSuccessful()) { - return $this->gitConfig = parse_ini_string($cmd->getOutput(), false, INI_SCANNER_RAW); + $this->gitConfig = array(); + preg_match_all('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches, PREG_SET_ORDER); + foreach ($matches as $match) { + $this->gitConfig[$match[1]] = $match[2]; + } + return $this->gitConfig; } return $this->gitConfig = array();