aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Lib/Storage
diff options
context:
space:
mode:
authorBenjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>2023-10-31 16:07:29 +0100
committerGitHub <noreply@github.com>2023-10-31 16:07:29 +0100
commitc52d5e418a55d088b392ff49a9cfafef079e53da (patch)
tree665d37685ce6fb282191b4015eb845129ea12f31 /apps/files_external/lib/Lib/Storage
parent48bfbf84ee3cf583d58fccb0b9ae57761db58901 (diff)
parenta45e12abc8881b347475877cd07f8fe33bfe8c77 (diff)
downloadnextcloud-server-c52d5e418a55d088b392ff49a9cfafef079e53da.tar.gz
nextcloud-server-c52d5e418a55d088b392ff49a9cfafef079e53da.zip
Merge pull request #41053 from nextcloud/bug/smb/in-place-case-rename
fix(files_external): on case insensitive system, block case change
Diffstat (limited to 'apps/files_external/lib/Lib/Storage')
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index c3ccc106239..2c0a412d341 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -93,6 +93,8 @@ class SMB extends Common implements INotifyStorage {
/** @var bool */
protected $showHidden;
+ private bool $caseSensitive;
+
/** @var bool */
protected $checkAcl;
@@ -139,6 +141,7 @@ class SMB extends Common implements INotifyStorage {
$this->root = rtrim($this->root, '/') . '/';
$this->showHidden = isset($params['show_hidden']) && $params['show_hidden'];
+ $this->caseSensitive = (bool) ($params['case_sensitive'] ?? true);
$this->checkAcl = isset($params['check_acl']) && $params['check_acl'];
$this->statCache = new CappedMemoryCache();
@@ -325,6 +328,12 @@ class SMB extends Common implements INotifyStorage {
if ($this->isRootDir($source) || $this->isRootDir($target)) {
return false;
}
+ if ($this->caseSensitive === false
+ && mb_strtolower($target) === mb_strtolower($source)
+ ) {
+ // Forbid changing case only on case-insensitive file system
+ return false;
+ }
$absoluteSource = $this->buildPath($source);
$absoluteTarget = $this->buildPath($target);
@@ -674,6 +683,16 @@ class SMB extends Common implements INotifyStorage {
public function file_exists($path) {
try {
+ if ($this->caseSensitive === false) {
+ $filename = basename($path);
+ $siblings = $this->getDirectoryContent(dirname($this->buildPath($path)));
+ foreach ($siblings as $sibling) {
+ if ($sibling['name'] === $filename) {
+ return true;
+ }
+ }
+ return false;
+ }
$this->getFileInfo($path);
return true;
} catch (\OCP\Files\NotFoundException $e) {