diff options
Diffstat (limited to 'lib/lib_rss.php')
| -rw-r--r-- | lib/lib_rss.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 60616b3ca..44123b746 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -109,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 |
