Skip to content

Commit

Permalink
Merge pull request #4884 from nextcloud/enh/noid/use-str_contains
Browse files Browse the repository at this point in the history
domain-validator: use `str_contains` instead of `strpos`
  • Loading branch information
szaimen authored Jun 24, 2024
2 parents d8fe250 + 40306c4 commit 5656f50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions php/domain-validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions php/src/Data/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}

Expand Down

0 comments on commit 5656f50

Please sign in to comment.