diff --git a/lib/functions/validate/function.validateUrl.php b/lib/functions/validate/function.validateUrl.php index 65ad0961..be7d51b5 100644 --- a/lib/functions/validate/function.validateUrl.php +++ b/lib/functions/validate/function.validateUrl.php @@ -28,18 +28,18 @@ function validateUrl($url) { + global $idna_convert; + if(strtolower(substr($url, 0, 7)) != "http://" && strtolower(substr($url, 0, 8)) != "https://") { $url = 'http://' . $url; } + + // needs converting + $url = $idna_convert->encode($url); - // there is a bug in php 5.2.13 - 5.3.2 which - // lets filter_var fail if the domain has - // a dash (-) in it. As the PHP_VERSION constant - // gives also patch-brandings, e.g. '5.3.2-pl0-gentoo' - // we just always use our regex - $pattern = '/^https?:\/\/([a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?\.)+[a-z]{2,6}$/i'; + $pattern = "/^https?\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?$/i"; if(preg_match($pattern, $url)) { return true;