Skip to content

Commit 46f4f6c

Browse files
author
epriestley
committed
Fix a fatal if a directory listing contains a non-file called 'readme'
Summary: See T1665. If you have a directory named 'readme', we try to read it as a README. Test Plan: Created a directory named 'readme', hit a similar fatal to the one in T1665, applied this patch, everything worked great. Reviewers: btrahan, vrana Reviewed By: vrana CC: aran Maniphest Tasks: T1665 Differential Revision: https://secure.phabricator.com/D3312
1 parent 91d0d92 commit 46f4f6c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/applications/diffusion/query/browse/DiffusionBrowseQuery.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,15 @@ final public function renderReadme(array $results) {
9595

9696
$readme = null;
9797
foreach ($results as $result) {
98+
$file_type = $result->getFileType();
99+
if (($file_type != ArcanistDiffChangeType::FILE_NORMAL) &&
100+
($file_type != ArcanistDiffChangeType::FILE_TEXT)) {
101+
// Skip directories, etc.
102+
continue;
103+
}
104+
98105
$path = $result->getPath();
106+
99107
if (preg_match('/^readme(|\.txt|\.remarkup|\.rainbow)$/i', $path)) {
100108
$readme = $result;
101109
break;
@@ -118,7 +126,6 @@ final public function renderReadme(array $results) {
118126
$content_query->loadFileContent();
119127
$readme_content = $content_query->getRawData();
120128

121-
122129
if (preg_match('/\\.txt$/', $readme->getPath())) {
123130
$readme_content = phutil_escape_html($readme_content);
124131
$readme_content = nl2br($readme_content);

0 commit comments

Comments
 (0)