aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_rss.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lib_rss.php')
-rw-r--r--lib/lib_rss.php31
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index e5fe73041..6342011c8 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -38,7 +38,7 @@ function classAutoloader($class) {
include(APP_PATH . '/Models/' . $components[1] . '.php');
return;
case 3: //Controllers, Exceptions
- @include(APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php');
+ include(APP_PATH . '/' . $components[2] . 's/' . $components[1] . $components[2] . '.php');
return;
}
} elseif (strpos($class, 'Minz') === 0) {
@@ -51,6 +51,21 @@ function classAutoloader($class) {
spl_autoload_register('classAutoloader');
//</Auto-loading>
+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);
+ $pos = strpos($url, $idn);
+ if ($pos !== false) {
+ return substr_replace($url, $puny, $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_puny($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)))) {
@@ -123,6 +139,7 @@ function customSimplePie() {
$limits = $system_conf->limits;
$simplePie = new SimplePie();
$simplePie->set_useragent(_t('gen.freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION);
+ $simplePie->set_syslog($system_conf->simplepie_syslog_enabled);
$simplePie->set_cache_location(CACHE_PATH);
$simplePie->set_cache_duration($limits['cache_duration']);
$simplePie->set_timeout($limits['timeout']);
@@ -180,7 +197,7 @@ function sanitizeHTML($data, $base = '') {
function get_content_by_parsing ($url, $path) {
require_once (LIB_PATH . '/lib_phpQuery.php');
- Minz_Log::notice('FreshRSS GET ' . url_remove_credentials($url));
+ Minz_Log::notice('FreshRSS GET ' . SimplePie_Misc::url_remove_credentials($url));
$html = file_get_contents ($url);
if ($html) {
@@ -429,13 +446,3 @@ function array_push_unique(&$array, $value) {
function array_remove(&$array, $value) {
$array = array_diff($array, array($value));
}
-
-
-/**
- * Sanitize a URL by removing HTTP credentials.
- * @param $url the URL to sanitize.
- * @return the same URL without HTTP credentials.
- */
-function url_remove_credentials($url) {
- return preg_replace('/[^\/]*:[^:]*@/', '', $url);
-}