Fix: kontakt

This commit is contained in:
2026-05-18 09:49:49 +02:00
parent a294675c16
commit d7c5ac64e7
4 changed files with 50 additions and 42 deletions

View File

@@ -75,9 +75,28 @@ class valid_Core {
* @param string URL
* @return boolean
*/
public static function url($url)
public static function url($url, $scheme = NULL)
{
return (bool) filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED);
if ( ! is_string($url) OR $url === '')
return FALSE;
$parts = @parse_url($url);
if ( ! is_array($parts) OR empty($parts['scheme']) OR empty($parts['host']))
return FALSE;
if ( ! preg_match('/^[a-z][a-z0-9+.-]*$/iD', $parts['scheme']))
return FALSE;
if ($scheme !== NULL)
{
$url_scheme = strtolower($parts['scheme']);
$schemes = array_map('strtolower', (array) $scheme);
return in_array($url_scheme, $schemes, TRUE);
}
return TRUE;
}
/**
@@ -335,4 +354,4 @@ class valid_Core {
return (bool) preg_match($pattern, (string) $str);
}
} // End valid
} // End valid