Skip to content

Commit

Permalink
Merge pull request #38308 from nextcloud/fix/check-for-php-auth-serve…
Browse files Browse the repository at this point in the history
…r-variables

fix(carddav): Check if SERVER variables are set before accessing them
  • Loading branch information
szaimen authored May 23, 2023
2 parents 0713c1c + 3c93ce9 commit 3894a86
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions apps/dav/lib/CardDAV/SystemAddressbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
use Sabre\CardDAV\Backend\SyncSupport;
use Sabre\CardDAV\Backend\BackendInterface;
use Sabre\CardDAV\Card;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\ICollection;
use Sabre\VObject\Component\VCard;
use Sabre\VObject\Reader;
use function array_filter;
Expand Down Expand Up @@ -234,12 +232,13 @@ private function isFederation(): bool {
}

/** @psalm-suppress NoInterfaceProperties */
if ($this->request->server['PHP_AUTH_USER'] !== 'system') {
$server = $this->request->server;
if (!isset($server['PHP_AUTH_USER']) || $server['PHP_AUTH_USER'] !== 'system') {
return false;
}

/** @psalm-suppress NoInterfaceProperties */
$sharedSecret = $this->request->server['PHP_AUTH_PW'];
$sharedSecret = $server['PHP_AUTH_PW'] ?? null;
if ($sharedSecret === null) {
return false;
}
Expand Down Expand Up @@ -299,7 +298,7 @@ public function delete() {
}

public function getACL() {
return array_filter(parent::getACL(), function($acl) {
return array_filter(parent::getACL(), function ($acl) {
if (in_array($acl['privilege'], ['{DAV:}write', '{DAV:}all'], true)) {
return false;
}
Expand Down

0 comments on commit 3894a86

Please sign in to comment.