Compare commits

..

2 commits

Author SHA1 Message Date
b6aa591f8c
Fix address comparison in AddressBookTest to use correct method for address retrieval
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
2025-03-27 13:45:50 -04:00
2179df3372
Normalize username and domain inputs to lowercase in various classes 2025-03-27 13:40:58 -04:00
5 changed files with 12 additions and 12 deletions

View file

@ -47,7 +47,7 @@
*/
public function getDomain(): ?string
{
return $this->domain;
return strtolower($this->domain);
}
/**

View file

@ -34,13 +34,18 @@
// Check if host is making the request & the identifier is not empty
try
{
$identifyAs = null;
if ($request->getPeer()->getUsername() === ReservedUsernames::HOST->value && $request->getIdentifyAs() !== null)
{
$identifyAs = $request->getIdentifyAs();
}
else
{
$identifyAs = $request->getPeer()->getAddress();
$requestingPeer = $request->getPeer();
if($requestingPeer->getUsername() !== ReservedUsernames::HOST->value)
{
$identifyAs = $requestingPeer->getAddress();
}
}
}
catch (DatabaseOperationException $e)

View file

@ -20,8 +20,8 @@
*/
public function __construct(string $username, string $domain)
{
$this->username = $username;
$this->domain = $domain;
$this->username = strtolower($username);
$this->domain = strtolower($domain);
}
/**
@ -78,11 +78,6 @@
*/
public function isExternal(): bool
{
if($this->isHost())
{
return false;
}
return $this->domain !== Configuration::getInstanceConfiguration()->getDomain();
}

View file

@ -978,12 +978,12 @@
*/
public static function resolvePeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer
{
if($peerAddress->getDomain() !== Configuration::getInstanceConfiguration()->getDomain())
if(strtolower($peerAddress->getDomain()) !== strtolower(Configuration::getInstanceConfiguration()->getDomain()))
{
return self::resolveExternalPeer($peerAddress, $identifiedAs);
}
if($peerAddress->getUsername() === ReservedUsernames::HOST->value)
if(strtolower($peerAddress->getUsername()) === strtolower(ReservedUsernames::HOST->value))
{
return new Peer([
'address' => sprintf('%s@%s', ReservedUsernames::HOST->value, Configuration::getInstanceConfiguration()->getDomain()),

View file

@ -767,7 +767,7 @@
$contact = $johnClient->addressBookGetContact($aliceClient->getIdentifiedAs());
$this->assertInstanceOf(Contact::class, $contact);
$this->assertEquals($aliceClient->getIdentifiedAs(), $contact->getAddress()->getAddress());
$this->assertEquals($aliceClient->getIdentifiedAs()->getAddress(), $contact->getAddress()->getAddress());
$this->expectException(RpcException::class);
$johnClient->addressBookGetContact('non-existent@coffee.com');