@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+8 -5
+8 -5
src/applications/diffusion/conduit/ConduitAPI_diffusion_browsequery_Method.php
··· 100 100 101 101 $results = array(); 102 102 foreach (explode("\0", rtrim($stdout)) as $line) { 103 - if (substr_count($line, ' ') < 4) { 103 + // NOTE: Limit to 5 components so we parse filenames with spaces in them 104 + // correctly. 105 + // NOTE: The output uses a mixture of tabs and one-or-more spaces to 106 + // delimit fields. 107 + $parts = preg_split('/\s+/', $line, 5); 108 + if (count($parts) < 5) { 104 109 throw new Exception( 105 110 pht( 106 - 'Expected "<mode> <type> <hash> <size> <name>", for ls-tree of '. 111 + 'Expected "<mode> <type> <hash> <size>\t<name>", for ls-tree of '. 107 112 '"%s:%s", got: %s', 108 113 $commit, 109 114 $path, 110 115 $line)); 111 116 } 112 117 113 - // NOTE: Limit to 5 components so we parse filenames with spaces in them 114 - // correctly. 115 - list($mode, $type, $hash, $size, $name) = preg_split('/\s+/', $line, 5); 118 + list($mode, $type, $hash, $size, $name) = $parts; 116 119 117 120 $path_result = new DiffusionRepositoryPath(); 118 121