From c523f5a4e7d346a02528c9143767d0505664d0da Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 31 Jul 2020 16:33:45 +0200 Subject: Relaxed to allow underscore _ in URL hostnames (#3133) * Relaxed to allow underscore _ in URL hostnames #fix https://github.com/FreshRSS/FreshRSS/issues/3132 https://bugs.php.net/bug.php?id=64948 * Minor fix in favicons redirect * Minor fix in relative HREF for favicons --- lib/lib_rss.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/lib_rss.php') diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 52c986433..8a58d2124 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -74,15 +74,19 @@ function idn_to_puny($url) { return $url; } -function checkUrl($url) { +function checkUrl($url, $fixScheme = true) { + $url = trim($url); if ($url == '') { return ''; } - if (!preg_match('#^https?://#i', $url)) { - $url = 'http://' . $url; + if ($fixScheme && !preg_match('#^https?://#i', $url)) { + $url = 'https://' . ltrim($url, '/'); } + $url = idn_to_puny($url); //PHP bug #53474 IDN - if (filter_var($url, FILTER_VALIDATE_URL)) { + $urlRelaxed = str_replace('_', 'z', $url); //PHP discussion #64948 Underscore + + if (filter_var($urlRelaxed, FILTER_VALIDATE_URL)) { return $url; } else { return false; -- cgit v1.2.3