mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 07:11:04 +01:00
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
This commit is contained in:
parent
91d0d92a9f
commit
46f4f6cf0a
1 changed files with 8 additions and 1 deletions
|
@ -95,7 +95,15 @@ abstract class DiffusionBrowseQuery {
|
|||
|
||||
$readme = null;
|
||||
foreach ($results as $result) {
|
||||
$file_type = $result->getFileType();
|
||||
if (($file_type != ArcanistDiffChangeType::FILE_NORMAL) &&
|
||||
($file_type != ArcanistDiffChangeType::FILE_TEXT)) {
|
||||
// Skip directories, etc.
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $result->getPath();
|
||||
|
||||
if (preg_match('/^readme(|\.txt|\.remarkup|\.rainbow)$/i', $path)) {
|
||||
$readme = $result;
|
||||
break;
|
||||
|
@ -118,7 +126,6 @@ abstract class DiffusionBrowseQuery {
|
|||
$content_query->loadFileContent();
|
||||
$readme_content = $content_query->getRawData();
|
||||
|
||||
|
||||
if (preg_match('/\\.txt$/', $readme->getPath())) {
|
||||
$readme_content = phutil_escape_html($readme_content);
|
||||
$readme_content = nl2br($readme_content);
|
||||
|
|
Loading…
Reference in a new issue