Normalize username and domain inputs to lowercase in various classes

This commit is contained in:
netkas 2025-03-27 13:40:58 -04:00
parent f36a7f8563
commit 2179df3372
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
4 changed files with 11 additions and 11 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()),