From 40306c4ed3678f20733ee9af4fdcf9440c61f50a Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Mon, 24 Jun 2024 14:32:14 +0200 Subject: [PATCH] domain-validator: use `str_contains` instead of `strpos` Signed-off-by: Simon L. --- php/domain-validator.php | 6 +++--- php/src/Data/ConfigurationManager.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/php/domain-validator.php b/php/domain-validator.php index 5f5ac00904f..57506b8a1c1 100644 --- a/php/domain-validator.php +++ b/php/domain-validator.php @@ -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); diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index 69e9bc6ebbc..b20938399ea 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -271,17 +271,17 @@ public function SetTalkRecordingEnabledState(int $value) : void { */ 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!"); }