diff options
| author | 2018-09-09 13:03:51 +0200 | |
|---|---|---|
| committer | 2018-09-09 13:03:51 +0200 | |
| commit | 44bd07e506ade204151c276fdc05994d51efdd7a (patch) | |
| tree | 2efe48133d2c874c65a99ae3a6cd92bb0dff4fe8 /lib | |
| parent | 3306a1679c2570c30d4b662c887b4a71ce147398 (diff) | |
| parent | 1802c1e9ae7d3d55a0e37e1cc2e7c0acc25f70ba (diff) | |
Merge pull request #2001 from FreshRSS/dev1.11.2
FreshRSS 1.11.2
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Minz/Url.php | 6 | ||||
| -rw-r--r-- | lib/lib_install.php | 2 | ||||
| -rw-r--r-- | lib/lib_rss.php | 20 |
3 files changed, 23 insertions, 5 deletions
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php index 99c0443c1..1c222ce25 100644 --- a/lib/Minz/Url.php +++ b/lib/Minz/Url.php @@ -27,6 +27,10 @@ class Minz_Url { $url_string = Minz_Request::getBaseUrl(); if ($url_string == '') { $url_string = Minz_Request::guessBaseUrl(); + if (PUBLIC_RELATIVE === '..') { + //TODO: Implement proper resolver of relative parts such as /test/./../ + $url_string = dirname($url_string); + } } if ($isArray) { $url_string .= PUBLIC_TO_INDEX_PATH; @@ -39,7 +43,7 @@ class Minz_Url { } if ($isArray) { - $url_string .= self::printUri($url, $encodage); + $url_string .= '/' . self::printUri($url, $encodage); } elseif ($encodage === 'html') { $url_string = Minz_Helper::htmlspecialchars_utf8($url_string . $url); } else { diff --git a/lib/lib_install.php b/lib/lib_install.php index 7305d8e28..d51a37e58 100644 --- a/lib/lib_install.php +++ b/lib/lib_install.php @@ -41,6 +41,7 @@ function checkRequirements($dbType = '') { $dom = class_exists('DOMDocument'); $xml = function_exists('xml_parser_create'); $json = function_exists('json_encode'); + $mbstring = extension_loaded('mbstring'); $data = DATA_PATH && is_writable(DATA_PATH); $cache = CACHE_PATH && is_writable(CACHE_PATH); $users = USERS_PATH && is_writable(USERS_PATH); @@ -61,6 +62,7 @@ function checkRequirements($dbType = '') { 'dom' => $dom ? 'ok' : 'ko', 'xml' => $xml ? 'ok' : 'ko', 'json' => $json ? 'ok' : 'ko', + 'mbstring' => $mbstring ? 'ok' : 'ko', 'data' => $data ? 'ok' : 'ko', 'cache' => $cache ? 'ok' : 'ko', 'users' => $users ? 'ok' : 'ko', diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 5f460862e..44123b746 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -21,6 +21,12 @@ if (!function_exists('json_encode')) { defined('JSON_UNESCAPED_UNICODE') or define('JSON_UNESCAPED_UNICODE', 256); //PHP 5.3 +if (!function_exists('mb_strcut')) { + function mb_strcut($str, $start, $length = null, $encoding = 'UTF-8') { + return substr($str, $start, $length); + } +} + /** * Build a directory path by concatenating a list of directory names. * @@ -103,24 +109,29 @@ function safe_ascii($text) { * localhost address. * * @param $address the address to test, can be an IP or a URL. - * @return true if server is accessible, false else. + * @return true if server is accessible, false otherwise. * @todo improve test with a more valid technique (e.g. test with an external server?) */ function server_is_public($address) { $host = parse_url($address, PHP_URL_HOST); $is_public = !in_array($host, array( - '127.0.0.1', 'localhost', 'localhost.localdomain', '[::1]', + 'ip6-localhost', 'localhost6', 'localhost6.localdomain6', )); - return $is_public; -} + if ($is_public) { + $ip = gethostbyname($host); + $is_public &= !preg_match('/^(10|127|172[.]16|192[.]168)[.]/', $ip); + $is_public &= !preg_match('/^(\[)?(::1$|fc00::|fe80::)/i', $ip); + } + return (bool)$is_public; +} function format_number($n, $precision = 0) { // number_format does not seem to be Unicode-compatible @@ -405,6 +416,7 @@ function check_install_php() { 'fileinfo' => extension_loaded('fileinfo'), 'dom' => class_exists('DOMDocument'), 'json' => extension_loaded('json'), + 'mbstring' => extension_loaded('mbstring'), 'zip' => extension_loaded('zip'), ); } |
