mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Fix an issue where DiffusionGitBrowseQuery incorrectly parses filenames with spaces
Summary: Split from D1921. We'll explode each line into too many parts currently, if the filename contains spaces. Also use -z to get \0 newlines. Test Plan: Browsed a directory containing files with spaces in their names, links etc were correct. Reviewers: nh, vrana, btrahan Reviewed By: btrahan CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1924
This commit is contained in:
parent
074ea25eab
commit
8c141fdfd1
1 changed files with 6 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -70,13 +70,15 @@ final class DiffusionGitBrowseQuery extends DiffusionBrowseQuery {
|
|||
}
|
||||
|
||||
list($stdout) = $repository->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 {
|
||||
|
|
Loading…
Reference in a new issue