namespace OC\Files\Storage;
+use OC\Files\Filesystem;
use OC\Files\Storage\Wrapper\Jail;
use OCP\Files\ForbiddenException;
use OCP\Files\Storage\IStorage;
}
+ private function treeContainsBlacklistedFile(string $path): bool {
+ $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
+ foreach ($iterator as $file) {
+ /** @var \SplFileInfo $file */
+ if (Filesystem::isFileBlacklisted($file->getBasename())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
public function rename($path1, $path2) {
$srcParent = dirname($path1);
$dstParent = dirname($path2);
}
return $result;
}
+
+ if ($this->treeContainsBlacklistedFile($this->getSourcePath($path1))) {
+ throw new ForbiddenException('Invalid path', false);
+ }
}
return rename($this->getSourcePath($path1), $this->getSourcePath($path2));
* @throws ForbiddenException
*/
public function getSourcePath($path) {
+ if (Filesystem::isFileBlacklisted($path)) {
+ throw new ForbiddenException('Invalid path', false);
+ }
+
$fullPath = $this->datadir . $path;
$currentPath = $path;
if ($this->allowSymlinks || $currentPath === '') {