From 93ceb42a108f44e0b1e6cbd0f7465284eba5e9ab Mon Sep 17 00:00:00 2001 From: ICTman1076 Date: Fri, 29 Nov 2019 22:44:26 +0000 Subject: [PATCH] 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. --- src/psm/Util/Server/ServerValidator.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/psm/Util/Server/ServerValidator.php b/src/psm/Util/Server/ServerValidator.php index e2f72d7f..d4b89aee 100644 --- a/src/psm/Util/Server/ServerValidator.php +++ b/src/psm/Util/Server/ServerValidator.php @@ -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;