diff --git a/src/applications/diffusion/query/browse/git/DiffusionGitBrowseQuery.php b/src/applications/diffusion/query/browse/git/DiffusionGitBrowseQuery.php index 973ae4a916..ad60353f33 100644 --- a/src/applications/diffusion/query/browse/git/DiffusionGitBrowseQuery.php +++ b/src/applications/diffusion/query/browse/git/DiffusionGitBrowseQuery.php @@ -1,7 +1,7 @@ execxLocalCommand( - 'ls-tree -l %s:%s', + 'ls-tree -z -l %s:%s', $commit, $path); $results = array(); - foreach (explode("\n", rtrim($stdout)) as $line) { - list($mode, $type, $hash, $size, $name) = preg_split('/\s+/', $line); + foreach (explode("\0", rtrim($stdout)) as $line) { + // NOTE: Limit to 5 components so we parse filenames with spaces in them + // correctly. + list($mode, $type, $hash, $size, $name) = preg_split('/\s+/', $line, 5); if ($type == 'tree') { $file_type = DifferentialChangeType::FILE_DIRECTORY; } else {