Merge pull request #38620 from fsamapoor/replace_strpos_calls_in_files_sharing_app

Refactors "strpos" calls in /apps/files_sharing
This commit is contained in:
Côme Chilliet 2023-06-05 11:19:46 +02:00 committed by GitHub
commit dea2f7dd42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View file

@ -129,7 +129,7 @@ class ExternalSharesController extends Controller {
* @return DataResponse
*/
public function testRemote($remote) {
if (strpos($remote, '#') !== false || strpos($remote, '?') !== false || strpos($remote, ';') !== false) {
if (str_contains($remote, '#') || str_contains($remote, '?') || str_contains($remote, ';')) {
return new DataResponse(false);
}

View file

@ -1841,7 +1841,7 @@ class ShareAPIController extends OCSController {
if ($share->getShareType() === IShare::TYPE_CIRCLE && \OC::$server->getAppManager()->isEnabledForUser('circles')
&& class_exists('\OCA\Circles\Api\v1\Circles')) {
$hasCircleId = (substr($share->getSharedWith(), -1) === ']');
$hasCircleId = (str_ends_with($share->getSharedWith(), ']'));
$shareWithStart = ($hasCircleId ? strrpos($share->getSharedWith(), '[') + 1 : 0);
$shareWithLength = ($hasCircleId ? -1 : strpos($share->getSharedWith(), ' '));
if ($shareWithLength === false) {

View file

@ -78,7 +78,7 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
$discoveryService = \OC::$server->query(\OCP\OCS\IDiscoveryService::class);
[$protocol, $remote] = explode('://', $this->cloudId->getRemote());
if (strpos($remote, '/')) {
if (str_contains($remote, '/')) {
[$host, $root] = explode('/', $remote, 2);
} else {
$host = $remote;

View file

@ -62,7 +62,7 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
<?php else: ?>
<!-- preview frame to open file in with viewer -->
<div id="imgframe"></div>
<?php if (isset($_['mimetype']) && strpos($_['mimetype'], 'image') === 0) { ?>
<?php if (isset($_['mimetype']) && str_starts_with($_['mimetype'], 'image')) { ?>
<div class="directDownload">
<div>
<?php p($_['filename'])?> (<?php p($_['fileSize']) ?>)