Hi,
currently it seems you cannot subscribe to feeds on hosts with internationalized domain names (IDNA) within tt-rss. You need to manually convert them to punycode to subscribe to them.
This patch adds code to detect internationalized domain names and convert them to punycode in fix_url().
---
diff --git a/include/functions2.php b/include/functions2.php
index 5b38f18..9b4b711 100644
--- a/include/functions2.php
+++ b/include/functions2.php
@@ -1776,6 +1776,14 @@
$url .= '/';
}
+ //convert IDNA hostname to punycode
+ $parts = parse_url($url);
+ if (mb_detect_encoding($parts['host']) != 'ASCII')
+ {
+ $parts['host'] = idn_to_ascii($parts['host']);
+ $url = build_url($parts);
+ }
+
if ($url != "http:///")
return $url;
else
diff --git a/install/index.php b/install/index.php
index 00e90df..4cf3dbd 100755
--- a/install/index.php
+++ b/install/index.php
@@ -71,6 +71,10 @@
array_push($errors, "PHP support for iconv is required to handle multiple charsets.");
}
+ if (!function_exists("idn_to_ascii")) {
+ array_push($errors, "PHP support for Internationalization Functions is required to handle Internationalized Domain Names.");
+ }
+
if (ini_get("safe_mode")) {
array_push($errors, "PHP safe mode setting is obsolete and not supported by tt-rss.");
}
---
There is a good explanation and code example here: http://gauth.fr/2013/02/using-curl-with ... ain-names/. This patch is heavily based on it. Only drawback is a new dependency on PECL intl (php5-intl on Debian).
Please review this patch.
[PATCH] Subscribe to feed with Internationalized Domain Name
- fox
- ^ me reading your posts ^
- Posts: 6318
- Joined: 27 Aug 2005, 22:53
- Location: Saint-Petersburg, Russia
- Contact:
Re: [PATCH] Subscribe to feed with Internationalized Domain Name
please submit patches via gitlab, thanks
e: just a few notes
1. tt-rss requires php 5.4 so this function should be baseline, no sanity check should be necessary
2. even if it is not available blocking everything because of a gimmick like IDN is a terrible idea, just check if function is there in the actual converting part
3. we are NOT depending on pecl, ever
e: just a few notes
1. tt-rss requires php 5.4 so this function should be baseline, no sanity check should be necessary
2. even if it is not available blocking everything because of a gimmick like IDN is a terrible idea, just check if function is there in the actual converting part
3. we are NOT depending on pecl, ever
Re: [PATCH] Subscribe to feed with Internationalized Domain Name
Thank you for your feedback, this is an updated version.
diff --git a/include/functions2.php b/include/functions2.php
index 5b38f18..6b6f5aa 100644
--- a/include/functions2.php
+++ b/include/functions2.php
@@ -1776,6 +1776,16 @@
$url .= '/';
}
+ //convert IDNA hostname to punycode if possible
+ if (function_exists("idn_to_ascii")) {
+ $parts = parse_url($url);
+ if (mb_detect_encoding($parts['host']) != 'ASCII')
+ {
+ $parts['host'] = idn_to_ascii($parts['host']);
+ $url = build_url($parts);
+ }
+ }
+
if ($url != "http:///")
return $url;
else
diff --git a/install/index.php b/install/index.php
index 00e90df..d9e370e 100755
--- a/install/index.php
+++ b/install/index.php
@@ -317,6 +317,10 @@
array_push($notices, "CURL and open_basedir combination breaks support for HTTP redirects. See the FAQ for more information.");
}
+ if (!function_exists("idn_to_ascii")) {
+ array_push($notices, "PHP support for Internationalization Functions is required to handle Internationalized Domain Names.");
+ }
+
if (count($notices) > 0) {
print_notice("Configuration check succeeded with minor problems:");
My gitlab user is bthaler, please grant me developer privileges and I will submit a merge request.
Thank You.
diff --git a/include/functions2.php b/include/functions2.php
index 5b38f18..6b6f5aa 100644
--- a/include/functions2.php
+++ b/include/functions2.php
@@ -1776,6 +1776,16 @@
$url .= '/';
}
+ //convert IDNA hostname to punycode if possible
+ if (function_exists("idn_to_ascii")) {
+ $parts = parse_url($url);
+ if (mb_detect_encoding($parts['host']) != 'ASCII')
+ {
+ $parts['host'] = idn_to_ascii($parts['host']);
+ $url = build_url($parts);
+ }
+ }
+
if ($url != "http:///")
return $url;
else
diff --git a/install/index.php b/install/index.php
index 00e90df..d9e370e 100755
--- a/install/index.php
+++ b/install/index.php
@@ -317,6 +317,10 @@
array_push($notices, "CURL and open_basedir combination breaks support for HTTP redirects. See the FAQ for more information.");
}
+ if (!function_exists("idn_to_ascii")) {
+ array_push($notices, "PHP support for Internationalization Functions is required to handle Internationalized Domain Names.");
+ }
+
if (count($notices) > 0) {
print_notice("Configuration check succeeded with minor problems:");
My gitlab user is bthaler, please grant me developer privileges and I will submit a merge request.
Thank You.
Who is online
Users browsing this forum: Google [Bot] and 4 guests