domain-validator: use str_contains instead of strpos

Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
Simon L. 2024-06-24 14:32:14 +02:00
parent 5dfe0b755a
commit 40306c4ed3
2 changed files with 6 additions and 6 deletions

View File

@ -2,11 +2,11 @@
$domain = $_GET['domain'] ?? '';
if (strpos($domain, '.') === false) {
if (!str_contains($domain, '.')) {
http_response_code(400);
} elseif (strpos($domain, '/') !== false) {
} elseif (str_contains($domain, '/')) {
http_response_code(400);
} elseif (strpos($domain, ':') !== false) {
} elseif (str_contains($domain, ':')) {
http_response_code(400);
} elseif (filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) === false) {
http_response_code(400);

View File

@ -271,17 +271,17 @@ class ConfigurationManager
*/
public function SetDomain(string $domain) : void {
// Validate that at least one dot is contained
if (strpos($domain, '.') === false) {
if (!str_contains($domain, '.')) {
throw new InvalidSettingConfigurationException("Domain must contain at least one dot!");
}
// Validate that no slashes are contained
if (strpos($domain, '/') !== false) {
if (str_contains($domain, '/')) {
throw new InvalidSettingConfigurationException("Domain must not contain slashes!");
}
// Validate that no colons are contained
if (strpos($domain, ':') !== false) {
if (str_contains($domain, ':')) {
throw new InvalidSettingConfigurationException("Domain must not contain colons!");
}