mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 06:26:57 +00:00
Merge pull request #4884 from nextcloud/enh/noid/use-str_contains
domain-validator: use `str_contains` instead of `strpos`
This commit is contained in:
commit
5656f50bd4
2 changed files with 6 additions and 6 deletions
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
$domain = $_GET['domain'] ?? '';
|
$domain = $_GET['domain'] ?? '';
|
||||||
|
|
||||||
if (strpos($domain, '.') === false) {
|
if (!str_contains($domain, '.')) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
} elseif (strpos($domain, '/') !== false) {
|
} elseif (str_contains($domain, '/')) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
} elseif (strpos($domain, ':') !== false) {
|
} elseif (str_contains($domain, ':')) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
} elseif (filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) === false) {
|
} elseif (filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) === false) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
|
|
|
||||||
|
|
@ -271,17 +271,17 @@ class ConfigurationManager
|
||||||
*/
|
*/
|
||||||
public function SetDomain(string $domain) : void {
|
public function SetDomain(string $domain) : void {
|
||||||
// Validate that at least one dot is contained
|
// 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!");
|
throw new InvalidSettingConfigurationException("Domain must contain at least one dot!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate that no slashes are contained
|
// Validate that no slashes are contained
|
||||||
if (strpos($domain, '/') !== false) {
|
if (str_contains($domain, '/')) {
|
||||||
throw new InvalidSettingConfigurationException("Domain must not contain slashes!");
|
throw new InvalidSettingConfigurationException("Domain must not contain slashes!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate that no colons are contained
|
// Validate that no colons are contained
|
||||||
if (strpos($domain, ':') !== false) {
|
if (str_contains($domain, ':')) {
|
||||||
throw new InvalidSettingConfigurationException("Domain must not contain colons!");
|
throw new InvalidSettingConfigurationException("Domain must not contain colons!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue