From 11900a55b366e4bf1487461bdcf2a98490d0a385 Mon Sep 17 00:00:00 2001 From: Pepijn Over Date: Mon, 28 Jul 2014 11:38:12 +0200 Subject: [PATCH] ServerValidator did not allow domains for services --- src/psm/Util/Server/ServerValidator.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/psm/Util/Server/ServerValidator.class.php b/src/psm/Util/Server/ServerValidator.class.php index 6177e9eb..5644114c 100644 --- a/src/psm/Util/Server/ServerValidator.class.php +++ b/src/psm/Util/Server/ServerValidator.class.php @@ -93,7 +93,11 @@ class ServerValidator { } break; case 'service': - if(!filter_var($value, FILTER_VALIDATE_IP)) { + if( + !filter_var($value, FILTER_VALIDATE_IP) + // domain regex as per http://stackoverflow.com/questions/106179/regular-expression-to-match-hostname-or-ip-address : + && !preg_match("/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])/", $value) + ) { throw new \InvalidArgumentException('server_ip_bad_service'); } break;