Signed-off-by: Morris Jobke <hey@morrisjobke.de>tags/v14.0.0beta1
@@ -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 = '/'; |
@@ -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, '/') . '/'; | |||
} | |||
/** |
@@ -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'); | |||
} |
@@ -63,11 +63,10 @@ class VersionParser { | |||
if(!$this->isValidVersionString($firstVersionNumber)) { | |||
break; | |||
} | |||
if(substr($firstVersion, 0, 1) === '>') { | |||
if(strpos($firstVersion, '>') === 0) { | |||
return new Version($firstVersionNumber, ''); | |||
} else { | |||
return new Version('', $firstVersionNumber); | |||
} | |||
return new Version('', $firstVersionNumber); | |||
case 2: | |||
if(!$this->isValidVersionString($firstVersionNumber) || !$this->isValidVersionString($secondVersionNumber)) { | |||
break; |
@@ -91,9 +91,7 @@ class TAR extends Archive { | |||
*/ | |||
public function addFolder($path) { | |||
$tmpBase = \OC::$server->getTempManager()->getTemporaryFolder(); | |||
if (substr($path, -1, 1) != '/') { | |||
$path .= '/'; | |||
} | |||
$path = rtrim($path, '/') . '/'; | |||
if ($this->fileExists($path)) { | |||
return false; | |||
} | |||
@@ -297,10 +295,7 @@ class TAR extends Archive { | |||
if ((array_search($path, $files) !== false) or (array_search($path . '/', $files) !== false)) { | |||
return true; | |||
} else { | |||
$folderPath = $path; | |||
if (substr($folderPath, -1, 1) != '/') { | |||
$folderPath .= '/'; | |||
} | |||
$folderPath = rtrim($path, '/') . '/'; | |||
$pathLength = strlen($folderPath); | |||
foreach ($files as $file) { | |||
if (strlen($file) > $pathLength and substr($file, 0, $pathLength) == $folderPath) { |
@@ -263,7 +263,7 @@ class Avatar implements IAvatar { | |||
* @return string | |||
*/ | |||
private function generateAvatar($userDisplayName, $size) { | |||
$text = strtoupper(substr($userDisplayName, 0, 1)); | |||
$text = strtoupper($userDisplayName[0]); | |||
$backgroundColor = $this->avatarBackgroundColor($userDisplayName); | |||
$im = imagecreatetruecolor($size, $size); |
@@ -839,8 +839,8 @@ class Filesystem { | |||
$path = preg_replace('#/{2,}#', '/', $path); | |||
//remove trailing slash | |||
if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') { | |||
$path = substr($path, 0, -1); | |||
if ($stripTrailingSlash and strlen($path) > 1) { | |||
$path = rtrim($path, '/'); | |||
} | |||
// remove trailing '/.' |
@@ -118,13 +118,9 @@ class DAV extends Common { | |||
$this->certPath = $certPath; | |||
} | |||
} | |||
$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 webdav storage configuration'); | |||
} |
@@ -698,7 +698,7 @@ class View { | |||
// do not allow deleting the root | |||
return false; | |||
} | |||
$postFix = (substr($path, -1, 1) === '/') ? '/' : ''; | |||
$postFix = (substr($path, -1) === '/') ? '/' : ''; | |||
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); | |||
$mount = Filesystem::getMountManager()->find($absolutePath . $postFix); | |||
if ($mount and $mount->getInternalPath($absolutePath) === '') { | |||
@@ -1067,7 +1067,7 @@ class View { | |||
* @return bool|null|string | |||
*/ | |||
public function hash($type, $path, $raw = false) { | |||
$postFix = (substr($path, -1, 1) === '/') ? '/' : ''; | |||
$postFix = (substr($path, -1) === '/') ? '/' : ''; | |||
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); | |||
if (Filesystem::isValidPath($path)) { | |||
$path = $this->getRelativePath($absolutePath); | |||
@@ -1119,7 +1119,7 @@ class View { | |||
* \OC\Files\Storage\Storage for delegation to a storage backend for execution | |||
*/ | |||
private function basicOperation($operation, $path, $hooks = [], $extraParam = null) { | |||
$postFix = (substr($path, -1, 1) === '/') ? '/' : ''; | |||
$postFix = (substr($path, -1) === '/') ? '/' : ''; | |||
$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); | |||
if (Filesystem::isValidPath($path) | |||
and !Filesystem::isFileBlacklisted($path) |
@@ -519,7 +519,7 @@ class Installer { | |||
foreach(\OC::$APPSROOTS as $app_dir) { | |||
if($dir = opendir( $app_dir['path'] )) { | |||
while( false !== ( $filename = readdir( $dir ))) { | |||
if( substr( $filename, 0, 1 ) != '.' and is_dir($app_dir['path']."/$filename") ) { | |||
if( $filename[0] !== '.' and is_dir($app_dir['path']."/$filename") ) { | |||
if( file_exists( $app_dir['path']."/$filename/appinfo/info.xml" )) { | |||
if(!Installer::isInstalled($filename)) { | |||
$info=OC_App::getAppInfo($filename); |
@@ -208,7 +208,7 @@ class PersonalInfo implements ISettings { | |||
$l = \OC::$server->getL10N('settings', $lang); | |||
// TRANSLATORS this is the language name for the language switcher in the personal settings and should be the localized version | |||
$potentialName = (string) $l->t('__language_name__'); | |||
if($l->getLanguageCode() === $lang && substr($potentialName, 0, 1) !== '_') {//first check if the language name is in the translation file | |||
if($l->getLanguageCode() === $lang && $potentialName[0] !== '_') {//first check if the language name is in the translation file | |||
$ln = array('code' => $lang, 'name' => $potentialName); | |||
} elseif ($lang === 'en') { | |||
$ln = ['code' => $lang, 'name' => 'English (US)']; |
@@ -784,16 +784,16 @@ class OC_Image implements \OCP\IImage { | |||
$color[1] = (($color[1] & 0xf800) >> 8) * 65536 + (($color[1] & 0x07e0) >> 3) * 256 + (($color[1] & 0x001f) << 3); | |||
break; | |||
case 8: | |||
$color = @unpack('n', $vide . substr($data, $p, 1)); | |||
$color = @unpack('n', $vide . ($data[$p] ?? '')); | |||
$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1]; | |||
break; | |||
case 4: | |||
$color = @unpack('n', $vide . substr($data, floor($p), 1)); | |||
$color = @unpack('n', $vide . ($data[floor($p)] ?? '')); | |||
$color[1] = ($p * 2) % 2 == 0 ? $color[1] >> 4 : $color[1] & 0x0F; | |||
$color[1] = (isset($palette[$color[1] + 1])) ? $palette[$color[1] + 1] : $palette[1]; | |||
break; | |||
case 1: | |||
$color = @unpack('n', $vide . substr($data, floor($p), 1)); | |||
$color = @unpack('n', $vide . ($data[floor($p)] ?? '')); | |||
switch (($p * 8) % 8) { | |||
case 0: | |||
$color[1] = $color[1] >> 7; |