mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Clean up AppwriteDomain validator
This commit is contained in:
1 parent
5ed0721c36
commit
6f50b4712f
1 file changed
+8
-8
@@ -14,11 +14,19 @@ class AppwriteDomain extends Domain
|
||||
|
||||
public function isValid($value): bool
|
||||
{
|
||||
if (empty($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reject domains with leading/trailing whitespace
|
||||
if (!is_string($value) || $value !== trim($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (\filter_var($value, FILTER_VALIDATE_DOMAIN) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (preg_match('/^https?:\/\//', $value)) {
|
||||
return false;
|
||||
}
|
||||
@@ -27,16 +35,8 @@ class AppwriteDomain extends Domain
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parent::isValid($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$domain = strtolower($value);
|
||||
|
||||
if ($domain === 'localhost' || $domain === 'api.localhost') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$parts = explode('.', $domain);
|
||||
$firstLabel = $parts[0];
|
||||
if (str_starts_with($firstLabel, 'commit-') || str_starts_with($firstLabel, 'branch-')) {
|
||||
|
||||
Reference in new issue
Block a user