From ba1338e6800d20311155be5f3a5d8c5738e88a62 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Wed, 26 Jan 2022 15:28:48 +0100 Subject: [PATCH] Return 404 when AJAX tries to list dir content but file given Due to a code mistake, the expected 404 return when AJAX tries to list a directory content with a non-directory file path given, does not happen. It instead fails with another exception. This commit restores the original intention to return 404 in the first place when passing a non-directory path with the "dir" parameter. Signed-off-by: MichaIng --- apps/files/ajax/list.php | 2 +- lib/private/Files/Filesystem.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index e43e5dd08e8ed..8a48d4fbe1f0d 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -38,7 +38,7 @@ try { $dirInfo = \OC\Files\Filesystem::getFileInfo($dir); - if (!$dirInfo || !$dirInfo->getType() === 'dir') { + if (!$dirInfo || $dirInfo->getType() !== 'dir') { http_response_code(404); exit(); } diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php index a9b1b87c8e76e..fb300134c8630 100644 --- a/lib/private/Files/Filesystem.php +++ b/lib/private/Files/Filesystem.php @@ -835,7 +835,7 @@ public static function normalizePath($path, $stripTrailingSlash = true, $isAbsol * @param string $path * @param boolean $includeMountPoints whether to add mountpoint sizes, * defaults to true - * @return \OC\Files\FileInfo|bool False if file does not exist + * @return \OC\Files\FileInfo|false False if file does not exist */ public static function getFileInfo($path, $includeMountPoints = true) { return self::$defaultInstance->getFileInfo($path, $includeMountPoints);