diff options
| author | 2019-11-22 18:30:09 +0100 | |
|---|---|---|
| committer | 2019-11-22 18:30:09 +0100 | |
| commit | 90c7292326538522a5df97b3f0a847b8a28f759f (patch) | |
| tree | 3e667d2cb629a6ff16db4196e8622d37bf10cf4e /lib/lib_rss.php | |
| parent | 09c088c62ece3b17615fb4e2addfa16663bb334f (diff) | |
| parent | 996b49f1d8fba327f24b5859f3bacb85edb79da9 (diff) | |
Merge pull request #2683 from FreshRSS/dev
FreshRSS 1.15.3
Diffstat (limited to 'lib/lib_rss.php')
| -rw-r--r-- | lib/lib_rss.php | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 137c7f2d5..357c02e82 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -49,13 +49,19 @@ spl_autoload_register('classAutoloader'); function idn_to_puny($url) { if (function_exists('idn_to_ascii')) { - $parts = parse_url($url); - if (!empty($parts['host'])) { - $idn = $parts['host']; - $puny = idn_to_ascii($idn, 0, INTL_IDNA_VARIANT_UTS46); + $idn = parse_url($url, PHP_URL_HOST); + if ($idn != '') { + // https://wiki.php.net/rfc/deprecate-and-remove-intl_idna_variant_2003 + if (defined('INTL_IDNA_VARIANT_UTS46')) { + $puny = idn_to_ascii($idn, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46); + } elseif (defined('INTL_IDNA_VARIANT_2003')) { + $puny = idn_to_ascii($idn, IDNA_DEFAULT, INTL_IDNA_VARIANT_2003); + } else { + $puny = idn_to_ascii($idn); + } $pos = strpos($url, $idn); - if ($pos !== false) { - return substr_replace($url, $puny, $pos, strlen($idn)); + if ($puny != '' && $pos !== false) { + $url = substr_replace($url, $puny, $pos, strlen($idn)); } } } |
