- validateUrl needed to idna-convert the url if its a domain, also needed new regex (subfolder, etc.)
This commit is contained in:
@@ -28,18 +28,18 @@
|
|||||||
|
|
||||||
function validateUrl($url)
|
function validateUrl($url)
|
||||||
{
|
{
|
||||||
|
global $idna_convert;
|
||||||
|
|
||||||
if(strtolower(substr($url, 0, 7)) != "http://"
|
if(strtolower(substr($url, 0, 7)) != "http://"
|
||||||
&& strtolower(substr($url, 0, 8)) != "https://")
|
&& strtolower(substr($url, 0, 8)) != "https://")
|
||||||
{
|
{
|
||||||
$url = 'http://' . $url;
|
$url = 'http://' . $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// needs converting
|
||||||
|
$url = $idna_convert->encode($url);
|
||||||
|
|
||||||
// there is a bug in php 5.2.13 - 5.3.2 which
|
$pattern = "/^https?\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?$/i";
|
||||||
// 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';
|
|
||||||
if(preg_match($pattern, $url))
|
if(preg_match($pattern, $url))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user