Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
when downloading from web, skip files that are not accessible
* avoids a 403, but enables download of resources that are not restricted
* single file downloads still cause 403

Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz authored and Backportbot committed Dec 19, 2019
commit 5bab0da93595e8aadf62433b309ff8b684d61902
12 changes: 9 additions & 3 deletions lib/private/Streamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ public function addDirRecursive(string $dir, string $internalDir = ''): void {

$userFolder = \OC::$server->getRootFolder()->get(Filesystem::getRoot());
/** @var Folder $dirNode */
$dirNode = $userFolder->get($rootDir);
$dirNode = $userFolder->get($dir);
$files = $dirNode->getDirectoryListing();

foreach($files as $file) {
if($file instanceof File) {
$fh = $file->fopen('r');
try {
$fh = $file->fopen('r');
} catch (NotPermittedException $e) {
continue;
}
$this->addFileFromStream(
$fh,
$internalDir . $file->getName(),
Expand All @@ -125,7 +129,9 @@ public function addDirRecursive(string $dir, string $internalDir = ''): void {
);
fclose($fh);
} elseif ($file instanceof Folder) {
$this->addDirRecursive($file->getName(), $internalDir);
if($file->isReadable()) {
$this->addDirRecursive($dir . '/' . $file->getName(), $internalDir);
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions lib/private/legacy/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ public static function get($dir, $files, $params = null) {
$userFolder = \OC::$server->getRootFolder()->get(\OC\Files\Filesystem::getRoot());
$file = $userFolder->get($file);
if($file instanceof \OC\Files\Node\File) {
$fh = $file->fopen('r');
try {
$fh = $file->fopen('r');
} catch (\OCP\Files\NotPermittedException $e) {
continue;
}
$fileSize = $file->getSize();
$fileTime = $file->getMTime();
} else {
Expand Down Expand Up @@ -309,7 +313,7 @@ private static function getSingleFile($view, $dir, $name, $params) {

OC_Util::obEnd();
$view->lockFile($filename, ILockingProvider::LOCK_SHARED);

$rangeArray = array();

if (isset($params['range']) && substr($params['range'], 0, 6) === 'bytes=') {
Expand Down