Browse Source

Call idn_to_ascii with INTL_IDNA_VARIANT_UTS46

Under PHP 7.2, calling `idn_to_ascii($idn)` results in a deprecation warning: 'INTL_IDNA_VARIANT_2003 is deprecated'
See https://secure.php.net/manual/en/function.idn-to-ascii.php 

Therefore, if possible, `idn_to_ascii($idn, 0, INTL_IDNA_VARIANT_UTS46)` should be used instead. `INTL_IDNA_VARIANT_UTS46` was introduced in PHP 5.4, so on versions before that, `idn_to_ascii($idn)` must still be used.

Fixed #1699
Craig Andrews 8 năm trước cách đây
mục cha
commit
aea78f4d99
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  1. 6 0
      lib/lib_rss.php

+ 6 - 0
lib/lib_rss.php

@@ -62,6 +62,12 @@ function idn_to_puny($url) {
 		$parts = parse_url($url);
 		if (!empty($parts['host'])) {
 			$idn = $parts['host'];
+			// INTL_IDNA_VARIANT_UTS46 is defined starting in PHP 5.4
+			if (defined('INTL_IDNA_VARIANT_UTS46')) {
+				$puny = idn_to_ascii($idn, 0, INTL_IDNA_VARIANT_UTS46);
+			} else {
+				$puny = idn_to_ascii($idn);
+			}
 			$puny = idn_to_ascii($idn);
 			$pos = strpos($url, $idn);
 			if ($pos !== false) {