catch exception thrown by new IdnaConverter when encoding a non-valid domain, fixes #1678

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2016-11-22 15:08:42 +01:00
parent 9838ff4da5
commit f8996ad767

View File

@@ -37,7 +37,11 @@ function validateUrl($url) {
}
// needs converting
$url = $idna_convert->encode($url);
try {
$url = $idna_convert->encode($url);
} catch (Exception $e) {
return false;
}
$pattern = "/^https?:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,4}(\:[0-9]+)?\/?(.+)?$/i";
if (preg_match($pattern, $url)) {