Skip to content

Commit ed24039

Browse files
committed
Issue #634: Explicitly check if path is directory
1 parent 042de3f commit ed24039

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

classes/local/store/object_file_system.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,14 @@ public function is_file_readable_externally_by_storedfile(stored_file $file) {
246246
* @return bool
247247
*/
248248
public function is_file_readable_externally_by_hash($contenthash) {
249-
if ($contenthash === sha1('')) {
250-
// Files with empty size are either directories or empty.
249+
$path = $this->get_external_path_from_hash($contenthash, false);
250+
251+
if ($contenthash === sha1('') && is_dir($path)) {
252+
// Explicitly check if it is a directory, handle empty files as normal.
251253
// We handle these virtually.
252254
return true;
253255
}
254256

255-
$path = $this->get_external_path_from_hash($contenthash, false);
256-
257257
// Note - it is not possible to perform a content recovery safely from a hash alone.
258258
return is_readable($path);
259259
}

0 commit comments

Comments
 (0)