From 1f6e3c271bf59106e9c177e3cea88d7edcbe5198 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Tue, 4 May 2010 10:30:02 +0000 Subject: [PATCH] - validateUrl needed to idna-convert the url if its a domain, also needed new regex (subfolder, etc.) --- lib/functions/validate/function.validateUrl.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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;