Skip to content

Commit

Permalink
Merge pull request #38620 from fsamapoor/replace_strpos_calls_in_file…
Browse files Browse the repository at this point in the history
…s_sharing_app

Refactors "strpos" calls in /apps/files_sharing
  • Loading branch information
come-nc authored Jun 5, 2023
2 parents 6a8c25f + 12e3594 commit dea2f7d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function testUrl($remote, $checkVersion = false) {
* @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);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ private function shareProviderResharingRights(string $userId, IShare $share, $no

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) {
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/External/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct($options) {
$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;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/templates/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<?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']) ?>)
Expand Down

0 comments on commit dea2f7d

Please sign in to comment.