mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Fix error detection for "ls-tree" output
Summary: Fixes T4223. The output of `ls-tree` is partially delimited by spaces and partially delimited by `\t`. The code I added in D7744 to help debug the issue in T4159 doesn't work properly for files with 7 or more bytes in their filesize, because the internals use `%7s`. Auditors: btrahan
This commit is contained in:
parent
b8b7bf8ad9
commit
052c83a613
1 changed files with 8 additions and 5 deletions
|
@ -100,19 +100,22 @@ final class ConduitAPI_diffusion_browsequery_Method
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach (explode("\0", rtrim($stdout)) as $line) {
|
foreach (explode("\0", rtrim($stdout)) as $line) {
|
||||||
if (substr_count($line, ' ') < 4) {
|
// NOTE: Limit to 5 components so we parse filenames with spaces in them
|
||||||
|
// correctly.
|
||||||
|
// NOTE: The output uses a mixture of tabs and one-or-more spaces to
|
||||||
|
// delimit fields.
|
||||||
|
$parts = preg_split('/\s+/', $line, 5);
|
||||||
|
if (count($parts) < 5) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
pht(
|
pht(
|
||||||
'Expected "<mode> <type> <hash> <size> <name>", for ls-tree of '.
|
'Expected "<mode> <type> <hash> <size>\t<name>", for ls-tree of '.
|
||||||
'"%s:%s", got: %s',
|
'"%s:%s", got: %s',
|
||||||
$commit,
|
$commit,
|
||||||
$path,
|
$path,
|
||||||
$line));
|
$line));
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Limit to 5 components so we parse filenames with spaces in them
|
list($mode, $type, $hash, $size, $name) = $parts;
|
||||||
// correctly.
|
|
||||||
list($mode, $type, $hash, $size, $name) = preg_split('/\s+/', $line, 5);
|
|
||||||
|
|
||||||
$path_result = new DiffusionRepositoryPath();
|
$path_result = new DiffusionRepositoryPath();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue