Normalize username and domain inputs to lowercase in various classes
This commit is contained in:
parent
f36a7f8563
commit
2179df3372
4 changed files with 11 additions and 11 deletions
|
@ -47,7 +47,7 @@
|
||||||
*/
|
*/
|
||||||
public function getDomain(): ?string
|
public function getDomain(): ?string
|
||||||
{
|
{
|
||||||
return $this->domain;
|
return strtolower($this->domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,13 +34,18 @@
|
||||||
// Check if host is making the request & the identifier is not empty
|
// Check if host is making the request & the identifier is not empty
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
$identifyAs = null;
|
||||||
if ($request->getPeer()->getUsername() === ReservedUsernames::HOST->value && $request->getIdentifyAs() !== null)
|
if ($request->getPeer()->getUsername() === ReservedUsernames::HOST->value && $request->getIdentifyAs() !== null)
|
||||||
{
|
{
|
||||||
$identifyAs = $request->getIdentifyAs();
|
$identifyAs = $request->getIdentifyAs();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$identifyAs = $request->getPeer()->getAddress();
|
$requestingPeer = $request->getPeer();
|
||||||
|
if($requestingPeer->getUsername() !== ReservedUsernames::HOST->value)
|
||||||
|
{
|
||||||
|
$identifyAs = $requestingPeer->getAddress();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (DatabaseOperationException $e)
|
catch (DatabaseOperationException $e)
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
*/
|
*/
|
||||||
public function __construct(string $username, string $domain)
|
public function __construct(string $username, string $domain)
|
||||||
{
|
{
|
||||||
$this->username = $username;
|
$this->username = strtolower($username);
|
||||||
$this->domain = $domain;
|
$this->domain = strtolower($domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,11 +78,6 @@
|
||||||
*/
|
*/
|
||||||
public function isExternal(): bool
|
public function isExternal(): bool
|
||||||
{
|
{
|
||||||
if($this->isHost())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->domain !== Configuration::getInstanceConfiguration()->getDomain();
|
return $this->domain !== Configuration::getInstanceConfiguration()->getDomain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -978,12 +978,12 @@
|
||||||
*/
|
*/
|
||||||
public static function resolvePeer(PeerAddress|string $peerAddress, null|PeerAddress|string $identifiedAs=null): Peer
|
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);
|
return self::resolveExternalPeer($peerAddress, $identifiedAs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($peerAddress->getUsername() === ReservedUsernames::HOST->value)
|
if(strtolower($peerAddress->getUsername()) === strtolower(ReservedUsernames::HOST->value))
|
||||||
{
|
{
|
||||||
return new Peer([
|
return new Peer([
|
||||||
'address' => sprintf('%s@%s', ReservedUsernames::HOST->value, Configuration::getInstanceConfiguration()->getDomain()),
|
'address' => sprintf('%s@%s', ReservedUsernames::HOST->value, Configuration::getInstanceConfiguration()->getDomain()),
|
||||||
|
|
Loading…
Add table
Reference in a new issue