Hopefully fix #704 (#791)

* Fix #704 - use regex instead of PHP's own function

* Updated .ltd length to 12

For domains like .company .services .business.
This commit is contained in:
ICTman1076 2019-11-29 22:44:26 +00:00 committed by Tim
parent aad4e2913d
commit 93ceb42a10
1 changed files with 2 additions and 1 deletions

View File

@ -88,7 +88,8 @@ class ServerValidator {
switch ($type) {
case 'website':
if (!filter_var($value, FILTER_VALIDATE_URL)) {
// url regex as per https://stackoverflow.com/a/3809435
if (!preg_match("/(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,12}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/g", $value)) {
throw new \InvalidArgumentException('server_ip_bad_website');
}
break;