aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2015-04-05 12:44:54 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2015-04-05 12:44:54 +0200
commitb812bb0c14b3fe5aeba102d4b8ea80e730f1ec31 (patch)
tree49d95f6d62c203a37cf4313ae8fa813686cb8d8c /lib
parent7b9ac8c58e49faaaf2d754768309e7865de1f4e1 (diff)
parent2d18910d02d92098257b96766e5b89a780daab0b (diff)
Merge remote-tracking branch 'origin/IDN' into dev
Diffstat (limited to 'lib')
-rw-r--r--lib/lib_rss.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index db8fa63d1..79be90a1c 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -51,6 +51,21 @@ function classAutoloader($class) {
spl_autoload_register('classAutoloader');
//</Auto-loading>
+function idn_to_punny($url) {
+ if (function_exists('idn_to_ascii')) {
+ $parts = parse_url($url);
+ if (!empty($parts['host'])) {
+ $idn = $parts['host'];
+ $punny = idn_to_ascii($idn);
+ $pos = strpos($url, $idn);
+ if ($pos !== false) {
+ return substr_replace($url, $punny, $pos, strlen($idn));
+ }
+ }
+ }
+ return $url;
+}
+
function checkUrl($url) {
if (empty ($url)) {
return '';
@@ -58,6 +73,7 @@ function checkUrl($url) {
if (!preg_match ('#^https?://#i', $url)) {
$url = 'http://' . $url;
}
+ $url = idn_to_punny($url); //PHP bug #53474 IDN
if (filter_var($url, FILTER_VALIDATE_URL) ||
(version_compare(PHP_VERSION, '5.3.3', '<') && (strpos($url, '-') > 0) && //PHP bug #51192
($url === filter_var($url, FILTER_SANITIZE_URL)))) {