Page MenuHomePhorge

D5259.1774862475.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D5259.1774862475.diff

diff --git a/src/app/Rules/ExternalEmail.php b/src/app/Rules/ExternalEmail.php
--- a/src/app/Rules/ExternalEmail.php
+++ b/src/app/Rules/ExternalEmail.php
@@ -20,7 +20,7 @@
*/
public function passes($attribute, $email): bool
{
- $v = Validator::make(['email' => $email], ['email' => 'required|email']);
+ $v = Validator::make(['email' => $email], ['email' => 'required|email:strict']);
if ($v->fails()) {
$this->message = \trans('validation.emailinvalid');
@@ -35,6 +35,18 @@
return false;
}
+ // don't allow IPv6 addresses in the domain part
+ if (str_contains($domain, ':')) {
+ $this->message = \trans('validation.emailinvalid');
+ return false;
+ }
+
+ // don't allow IPv4 addresses in the domain part
+ if (preg_match('/^[0-9.]+$/', $domain)) {
+ $this->message = \trans('validation.emailinvalid');
+ return false;
+ }
+
return true;
}
diff --git a/src/tests/Unit/Rules/ExternalEmailTest.php b/src/tests/Unit/Rules/ExternalEmailTest.php
--- a/src/tests/Unit/Rules/ExternalEmailTest.php
+++ b/src/tests/Unit/Rules/ExternalEmailTest.php
@@ -42,11 +42,17 @@
['example.org', 'The specified email address is invalid.'],
['@example.org', 'The specified email address is invalid.'],
['test@localhost', 'The specified email address is invalid.'],
+ ['nick@mykolab..com', 'The specified email address is invalid.'],
+ ['nick..test@mykolab.com', 'The specified email address is invalid.'],
+ ['test@123.123.123.123', 'The specified email address is invalid.'],
+ ['test@2001:db8::8a2e:370:7334', 'The specified email address is invalid.'],
// FIXME: empty - valid ??????
['', null],
// valid
['test@domain.tld', null],
['&@example.org', null],
+ ['test@example123.com', null],
+ ['test@123.com', null],
];
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 30, 9:21 AM (4 d, 11 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18749709
Default Alt Text
D5259.1774862475.diff (2 KB)

Event Timeline