Browse Source

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 <micha@dietpi.com>
tags/v24.0.0beta1
MichaIng 2 years ago
parent
commit
ba1338e680
2 changed files with 2 additions and 2 deletions
  1. 1
    1
      apps/files/ajax/list.php
  2. 1
    1
      lib/private/Files/Filesystem.php

+ 1
- 1
apps/files/ajax/list.php View File

@@ -38,7 +38,7 @@ $dir = \OC\Files\Filesystem::normalizePath($dir);

try {
$dirInfo = \OC\Files\Filesystem::getFileInfo($dir);
if (!$dirInfo || !$dirInfo->getType() === 'dir') {
if (!$dirInfo || $dirInfo->getType() !== 'dir') {
http_response_code(404);
exit();
}

+ 1
- 1
lib/private/Files/Filesystem.php View File

@@ -835,7 +835,7 @@ class Filesystem {
* @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);

Loading…
Cancel
Save