aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Files')
-rw-r--r--lib/private/Files/Cache/Cache.php2
-rw-r--r--lib/private/Files/Cache/LocalRootScanner.php2
-rw-r--r--lib/private/Files/Cache/Propagator.php2
-rw-r--r--lib/private/Files/Cache/Scanner.php2
-rw-r--r--lib/private/Files/Cache/SearchBuilder.php2
-rw-r--r--lib/private/Files/Cache/Wrapper/CacheJail.php2
-rw-r--r--lib/private/Files/Config/UserMountCache.php2
-rw-r--r--lib/private/Files/Filesystem.php2
-rw-r--r--lib/private/Files/Mount/MountPoint.php2
-rw-r--r--lib/private/Files/Mount/RootMountProvider.php2
-rw-r--r--lib/private/Files/Node/Folder.php6
-rw-r--r--lib/private/Files/ObjectStore/S3Signature.php4
-rw-r--r--lib/private/Files/SetupManager.php6
-rw-r--r--lib/private/Files/Storage/Common.php2
-rw-r--r--lib/private/Files/Storage/DAV.php8
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php4
-rw-r--r--lib/private/Files/Storage/Wrapper/Jail.php2
-rw-r--r--lib/private/Files/Storage/Wrapper/Quota.php4
-rw-r--r--lib/private/Files/Type/Detection.php8
-rw-r--r--lib/private/Files/Utils/PathHelper.php4
-rw-r--r--lib/private/Files/View.php4
21 files changed, 36 insertions, 36 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 933fee5630f..f085f8ade5e 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -836,7 +836,7 @@ class Cache implements ICache {
* @return ICacheEntry[] an array of cache entries where the mimetype matches the search
*/
public function searchByMime($mimetype) {
- if (strpos($mimetype, '/') === false) {
+ if (!str_contains($mimetype, '/')) {
$operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%');
} else {
$operator = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', $mimetype);
diff --git a/lib/private/Files/Cache/LocalRootScanner.php b/lib/private/Files/Cache/LocalRootScanner.php
index 0b6bc497ea3..df5ddd0075b 100644
--- a/lib/private/Files/Cache/LocalRootScanner.php
+++ b/lib/private/Files/Cache/LocalRootScanner.php
@@ -44,6 +44,6 @@ class LocalRootScanner extends Scanner {
private function shouldScanPath(string $path): bool {
$path = trim($path, '/');
- return $path === '' || strpos($path, 'appdata_') === 0 || strpos($path, '__groupfolders') === 0;
+ return $path === '' || str_starts_with($path, 'appdata_') || str_starts_with($path, '__groupfolders');
}
}
diff --git a/lib/private/Files/Cache/Propagator.php b/lib/private/Files/Cache/Propagator.php
index 70fc238d9be..327d0d80bf2 100644
--- a/lib/private/Files/Cache/Propagator.php
+++ b/lib/private/Files/Cache/Propagator.php
@@ -71,7 +71,7 @@ class Propagator implements IPropagator {
public function propagateChange($internalPath, $time, $sizeDifference = 0) {
// Do not propagate changes in ignored paths
foreach ($this->ignore as $ignore) {
- if (strpos($internalPath, $ignore) === 0) {
+ if (str_starts_with($internalPath, $ignore)) {
return;
}
}
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php
index e3a08264716..a34f1db3195 100644
--- a/lib/private/Files/Cache/Scanner.php
+++ b/lib/private/Files/Cache/Scanner.php
@@ -521,7 +521,7 @@ class Scanner extends BasicEmitter implements IScanner {
if (pathinfo($file, PATHINFO_EXTENSION) === 'part') {
return true;
}
- if (strpos($file, '.part/') !== false) {
+ if (str_contains($file, '.part/')) {
return true;
}
diff --git a/lib/private/Files/Cache/SearchBuilder.php b/lib/private/Files/Cache/SearchBuilder.php
index 63dc4b9cd0e..c9f35ccd095 100644
--- a/lib/private/Files/Cache/SearchBuilder.php
+++ b/lib/private/Files/Cache/SearchBuilder.php
@@ -152,7 +152,7 @@ class SearchBuilder {
$field = 'mimepart';
$value = (int)$this->mimetypeLoader->getId($matches[1]);
$type = ISearchComparison::COMPARE_EQUAL;
- } elseif (strpos($value, '%') !== false) {
+ } elseif (str_contains($value, '%')) {
throw new \InvalidArgumentException('Unsupported query value for mimetype: ' . $value . ', only values in the format "mime/type" or "mime/%" are supported');
} else {
$field = 'mimetype';
diff --git a/lib/private/Files/Cache/Wrapper/CacheJail.php b/lib/private/Files/Cache/Wrapper/CacheJail.php
index a5075ceef86..2885a8bf5e0 100644
--- a/lib/private/Files/Cache/Wrapper/CacheJail.php
+++ b/lib/private/Files/Cache/Wrapper/CacheJail.php
@@ -328,7 +328,7 @@ class CacheJail extends CacheWrapper {
}
public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry {
- if ($this->getGetUnjailedRoot() === '' || strpos($rawEntry->getPath(), $this->getGetUnjailedRoot()) === 0) {
+ if ($this->getGetUnjailedRoot() === '' || str_starts_with($rawEntry->getPath(), $this->getGetUnjailedRoot())) {
$rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry);
if ($rawEntry) {
$jailedPath = $this->getJailedPath($rawEntry->getPath());
diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php
index 9838b0a213c..90f94b6598e 100644
--- a/lib/private/Files/Config/UserMountCache.php
+++ b/lib/private/Files/Config/UserMountCache.php
@@ -487,7 +487,7 @@ class UserMountCache implements IUserMountCache {
$path = rtrim($path, '/') . '/';
$mounts = $this->getMountsForUser($user);
return array_filter($mounts, function (ICachedMountInfo $mount) use ($path) {
- return $mount->getMountPoint() !== $path && strpos($mount->getMountPoint(), $path) === 0;
+ return $mount->getMountPoint() !== $path && str_starts_with($mount->getMountPoint(), $path);
});
}
}
diff --git a/lib/private/Files/Filesystem.php b/lib/private/Files/Filesystem.php
index 2eab4c58a0c..5f7c0c403db 100644
--- a/lib/private/Files/Filesystem.php
+++ b/lib/private/Files/Filesystem.php
@@ -451,7 +451,7 @@ class Filesystem {
if (!$path || $path[0] !== '/') {
$path = '/' . $path;
}
- if (strpos($path, '/../') !== false || strrchr($path, '/') === '/..') {
+ if (str_contains($path, '/../') || strrchr($path, '/') === '/..') {
return false;
}
return true;
diff --git a/lib/private/Files/Mount/MountPoint.php b/lib/private/Files/Mount/MountPoint.php
index 20e08120080..f526928cc15 100644
--- a/lib/private/Files/Mount/MountPoint.php
+++ b/lib/private/Files/Mount/MountPoint.php
@@ -121,7 +121,7 @@ class MountPoint implements IMountPoint {
$this->storage = $this->loader->wrap($this, $storage);
} else {
// Update old classes to new namespace
- if (strpos($storage, 'OC_Filestorage_') !== false) {
+ if (str_contains($storage, 'OC_Filestorage_')) {
$storage = '\OC\Files\Storage\\' . substr($storage, 15);
}
$this->class = $storage;
diff --git a/lib/private/Files/Mount/RootMountProvider.php b/lib/private/Files/Mount/RootMountProvider.php
index b301fc6dd14..794421181c7 100644
--- a/lib/private/Files/Mount/RootMountProvider.php
+++ b/lib/private/Files/Mount/RootMountProvider.php
@@ -64,7 +64,7 @@ class RootMountProvider implements IRootMountProvider {
// instantiate object store implementation
$name = $config['class'];
- if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {
+ if (str_starts_with($name, 'OCA\\') && substr_count($name, '\\') >= 2) {
$segments = explode('\\', $name);
OC_App::loadApp(strtolower($segments[1]));
}
diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php
index 1d6d88bafe6..44f47e92ca0 100644
--- a/lib/private/Files/Node/Folder.php
+++ b/lib/private/Files/Node/Folder.php
@@ -88,7 +88,7 @@ class Folder extends Node implements \OCP\Files\Folder {
* @return bool
*/
public function isSubNode($node) {
- return strpos($node->getPath(), $this->path . '/') === 0;
+ return str_starts_with($node->getPath(), $this->path . '/');
}
/**
@@ -284,7 +284,7 @@ class Folder extends Node implements \OCP\Files\Folder {
* @return Node[]
*/
public function searchByMime($mimetype) {
- if (strpos($mimetype, '/') === false) {
+ if (!str_contains($mimetype, '/')) {
$query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%'));
} else {
$query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', $mimetype));
@@ -339,7 +339,7 @@ class Folder extends Node implements \OCP\Files\Folder {
$absolutePath = '/' . ltrim($cacheEntry->getPath(), '/');
$currentPath = rtrim($this->path, '/') . '/';
- if (strpos($absolutePath, $currentPath) !== 0) {
+ if (!str_starts_with($absolutePath, $currentPath)) {
return [];
}
diff --git a/lib/private/Files/ObjectStore/S3Signature.php b/lib/private/Files/ObjectStore/S3Signature.php
index 64b994bac22..cf3d29c4185 100644
--- a/lib/private/Files/ObjectStore/S3Signature.php
+++ b/lib/private/Files/ObjectStore/S3Signature.php
@@ -107,7 +107,7 @@ class S3Signature implements SignatureInterface {
// Move X-Amz-* headers to the query string
foreach ($request->getHeaders() as $name => $header) {
$name = strtolower($name);
- if (strpos($name, 'x-amz-') === 0) {
+ if (str_starts_with($name, 'x-amz-')) {
$query[$name] = implode(',', $header);
}
}
@@ -169,7 +169,7 @@ class S3Signature implements SignatureInterface {
$headers = [];
foreach ($request->getHeaders() as $name => $header) {
$name = strtolower($name);
- if (strpos($name, 'x-amz-') === 0) {
+ if (str_starts_with($name, 'x-amz-')) {
$value = implode(',', $header);
if (strlen($value) > 0) {
$headers[$name] = $name . ':' . $value;
diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php
index 01ce4a1cc59..2198c8c60b7 100644
--- a/lib/private/Files/SetupManager.php
+++ b/lib/private/Files/SetupManager.php
@@ -294,7 +294,7 @@ class SetupManager {
$userRoot = '/' . $user->getUID() . '/';
$mounts = $this->mountManager->getAll();
$mounts = array_filter($mounts, function (IMountPoint $mount) use ($userRoot) {
- return strpos($mount->getMountPoint(), $userRoot) === 0;
+ return str_starts_with($mount->getMountPoint(), $userRoot);
});
$allProviders = array_map(function (IMountProvider $provider) {
return get_class($provider);
@@ -365,7 +365,7 @@ class SetupManager {
* @return IUser|null
*/
private function getUserForPath(string $path) {
- if (strpos($path, '/__groupfolders') === 0) {
+ if (str_starts_with($path, '/__groupfolders')) {
return null;
} elseif (substr_count($path, '/') < 2) {
if ($user = $this->userSession->getUser()) {
@@ -373,7 +373,7 @@ class SetupManager {
} else {
return null;
}
- } elseif (strpos($path, '/appdata_' . \OC_Util::getInstanceId()) === 0 || strpos($path, '/files_external/') === 0) {
+ } elseif (str_starts_with($path, '/appdata_' . \OC_Util::getInstanceId()) || str_starts_with($path, '/files_external/')) {
return null;
} else {
[, $userId] = explode('/', $path);
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php
index cd9a05a2a1d..5ab411434d0 100644
--- a/lib/private/Files/Storage/Common.php
+++ b/lib/private/Files/Storage/Common.php
@@ -577,7 +577,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
*/
private function scanForInvalidCharacters($fileName, $invalidChars) {
foreach (str_split($invalidChars) as $char) {
- if (strpos($fileName, $char) !== false) {
+ if (str_contains($fileName, $char)) {
throw new InvalidCharacterInPathException();
}
}
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index b332f3b7c4a..6a05f54a0b4 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -769,16 +769,16 @@ class DAV extends Common {
*/
protected function parsePermissions($permissionsString) {
$permissions = Constants::PERMISSION_READ;
- if (strpos($permissionsString, 'R') !== false) {
+ if (str_contains($permissionsString, 'R')) {
$permissions |= Constants::PERMISSION_SHARE;
}
- if (strpos($permissionsString, 'D') !== false) {
+ if (str_contains($permissionsString, 'D')) {
$permissions |= Constants::PERMISSION_DELETE;
}
- if (strpos($permissionsString, 'W') !== false) {
+ if (str_contains($permissionsString, 'W')) {
$permissions |= Constants::PERMISSION_UPDATE;
}
- if (strpos($permissionsString, 'CK') !== false) {
+ if (str_contains($permissionsString, 'CK')) {
$permissions |= Constants::PERMISSION_CREATE;
$permissions |= Constants::PERMISSION_UPDATE;
}
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index 9c0e6c91463..ab3873a7ec0 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -922,7 +922,7 @@ class Encryption extends Wrapper {
}
$firstBlock = $this->readFirstBlock($path);
- if (substr($firstBlock, 0, strlen(Util::HEADER_START)) === Util::HEADER_START) {
+ if (str_starts_with($firstBlock, Util::HEADER_START)) {
$headerSize = $this->util->getHeaderSize();
}
@@ -937,7 +937,7 @@ class Encryption extends Wrapper {
*/
protected function parseRawHeader($rawHeader) {
$result = [];
- if (substr($rawHeader, 0, strlen(Util::HEADER_START)) === Util::HEADER_START) {
+ if (str_starts_with($rawHeader, Util::HEADER_START)) {
$header = $rawHeader;
$endAt = strpos($header, Util::HEADER_END);
if ($endAt !== false) {
diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php
index caf039d4cca..1921ac27848 100644
--- a/lib/private/Files/Storage/Wrapper/Jail.php
+++ b/lib/private/Files/Storage/Wrapper/Jail.php
@@ -72,7 +72,7 @@ class Jail extends Wrapper {
public function getJailedPath($path) {
$root = rtrim($this->rootPath, '/') . '/';
- if ($path !== $this->rootPath && strpos($path, $root) !== 0) {
+ if ($path !== $this->rootPath && !str_starts_with($path, $root)) {
return null;
} else {
$path = substr($path, strlen($this->rootPath));
diff --git a/lib/private/Files/Storage/Wrapper/Quota.php b/lib/private/Files/Storage/Wrapper/Quota.php
index cfb2c455a2c..5786dba5114 100644
--- a/lib/private/Files/Storage/Wrapper/Quota.php
+++ b/lib/private/Files/Storage/Wrapper/Quota.php
@@ -109,7 +109,7 @@ class Quota extends Wrapper {
if (!$this->hasQuota()) {
return $this->storage->free_space($path);
}
- if ($this->getQuota() < 0 || strpos($path, 'cache') === 0 || strpos($path, 'uploads') === 0) {
+ if ($this->getQuota() < 0 || str_starts_with($path, 'cache') || str_starts_with($path, 'uploads')) {
return $this->storage->free_space($path);
} else {
$used = $this->getSize($this->sizeRoot);
@@ -207,7 +207,7 @@ class Quota extends Wrapper {
* Only apply quota for files, not metadata, trash or others
*/
private function shouldApplyQuota(string $path): bool {
- return strpos(ltrim($path, '/'), 'files/') === 0;
+ return str_starts_with(ltrim($path, '/'), 'files/');
}
/**
diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php
index 432bc4c4d6d..d3f548d6615 100644
--- a/lib/private/Files/Type/Detection.php
+++ b/lib/private/Files/Type/Detection.php
@@ -116,7 +116,7 @@ class Detection implements IMimeTypeDetector {
// Update the alternative mimetypes to avoid having to look them up each time.
foreach ($this->mimetypes as $extension => $mimeType) {
- if (strpos($extension, '_comment') === 0) {
+ if (str_starts_with($extension, '_comment')) {
continue;
}
$this->secureMimeTypes[$mimeType[0]] = $mimeType[1] ?? $mimeType[0];
@@ -238,7 +238,7 @@ class Detection implements IMimeTypeDetector {
finfo_close($finfo);
if ($info) {
$info = strtolower($info);
- $mimeType = strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info;
+ $mimeType = str_contains($info, ';') ? substr($info, 0, strpos($info, ';')) : $info;
$mimeType = $this->getSecureMimeType($mimeType);
if ($mimeType !== 'application/octet-stream') {
return $mimeType;
@@ -246,7 +246,7 @@ class Detection implements IMimeTypeDetector {
}
}
- if (strpos($path, '://') !== false && strpos($path, 'file://') === 0) {
+ if (str_contains($path, '://') && str_starts_with($path, 'file://')) {
// Is the file wrapped in a stream?
return 'application/octet-stream';
}
@@ -308,7 +308,7 @@ class Detection implements IMimeTypeDetector {
if (function_exists('finfo_open') && function_exists('finfo_file')) {
$finfo = finfo_open(FILEINFO_MIME);
$info = finfo_buffer($finfo, $data);
- return strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info;
+ return str_contains($info, ';') ? substr($info, 0, strpos($info, ';')) : $info;
}
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile();
diff --git a/lib/private/Files/Utils/PathHelper.php b/lib/private/Files/Utils/PathHelper.php
index 07985e884ce..0fb7ba663cc 100644
--- a/lib/private/Files/Utils/PathHelper.php
+++ b/lib/private/Files/Utils/PathHelper.php
@@ -37,7 +37,7 @@ class PathHelper {
}
if ($path === $root) {
return '/';
- } elseif (strpos($path, $root . '/') !== 0) {
+ } elseif (!str_starts_with($path, $root . '/')) {
return null;
} else {
$path = substr($path, strlen($root));
@@ -60,7 +60,7 @@ class PathHelper {
$path = '/' . $path;
}
//remove duplicate slashes
- while (strpos($path, '//') !== false) {
+ while (str_contains($path, '//')) {
$path = str_replace('//', '/', $path);
}
//remove trailing slash
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index a73b60989fd..d256003537d 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -168,7 +168,7 @@ class View {
// missing slashes can cause wrong matches!
$root = rtrim($this->fakeRoot, '/') . '/';
- if (strpos($path, $root) !== 0) {
+ if (!str_starts_with($path, $root)) {
return null;
} else {
$path = substr($path, strlen($this->fakeRoot));
@@ -2079,7 +2079,7 @@ class View {
return ($pathSegments[2] === 'files') && (count($pathSegments) > 3);
}
- return strpos($path, '/appdata_') !== 0;
+ return !str_starts_with($path, '/appdata_');
}
/**