summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-01-26 15:40:44 +0100
committerGitHub <noreply@github.com>2018-01-26 15:40:44 +0100
commit4c38d1ed01a180b2c086571ab1b6167c173c203b (patch)
treec0f5ffb382534fb468193f453499aa69c4aa5cf9 /apps
parentca493ab5b1288d53f203d74117a8e636a606e633 (diff)
parent9ff51aafc518460e6c45996f09e9fe74e5f8d2e8 (diff)
downloadnextcloud-server-4c38d1ed01a180b2c086571ab1b6167c173c203b.tar.gz
nextcloud-server-4c38d1ed01a180b2c086571ab1b6167c173c203b.zip
Merge pull request #8054 from nextcloud/substr-use-index
Use index based string access for substr with length of 1
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/Lib/Storage/OwnCloud.php5
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php9
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php10
3 files changed, 6 insertions, 18 deletions
diff --git a/apps/files_external/lib/Lib/Storage/OwnCloud.php b/apps/files_external/lib/Lib/Storage/OwnCloud.php
index d846fa811a0..d56e6b66145 100644
--- a/apps/files_external/lib/Lib/Storage/OwnCloud.php
+++ b/apps/files_external/lib/Lib/Storage/OwnCloud.php
@@ -61,10 +61,7 @@ class OwnCloud extends \OC\Files\Storage\DAV{
}
if (isset($params['root'])){
- $root = $params['root'];
- if (substr($root, 0, 1) !== '/'){
- $root = '/' . $root;
- }
+ $root = '/' . ltrim($params['root'], '/');
}
else{
$root = '/';
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index 22162fa61cf..6bd77dd2496 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -103,13 +103,8 @@ class SFTP extends \OC\Files\Storage\Common {
$this->root
= isset($params['root']) ? $this->cleanPath($params['root']) : '/';
- if ($this->root[0] !== '/') {
- $this->root = '/' . $this->root;
- }
-
- if (substr($this->root, -1, 1) !== '/') {
- $this->root .= '/';
- }
+ $this->root = '/' . ltrim($this->root, '/');
+ $this->root = rtrim($this->root, '/') . '/';
}
/**
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index d8bbe8c4718..58a6f65990f 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -84,13 +84,9 @@ class SMB extends Common implements INotifyStorage {
}
$this->share = $this->server->getShare(trim($params['share'], '/'));
- $this->root = isset($params['root']) ? $params['root'] : '/';
- if (!$this->root || $this->root[0] !== '/') {
- $this->root = '/' . $this->root;
- }
- if (substr($this->root, -1, 1) !== '/') {
- $this->root .= '/';
- }
+ $this->root = $params['root'] ?? '/';
+ $this->root = '/' . ltrim($this->root, '/');
+ $this->root = rtrim($this->root, '/') . '/';
} else {
throw new \Exception('Invalid configuration');
}