From 2aff347b2e942286292b21e0b20d93ab85220a17 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 4 Jan 2020 23:35:42 +0100 Subject: Fix wrong getHeader refactoring (#2749) * Fix wrong getHeader refactoring Fix regression introduced by https://github.com/FreshRSS/FreshRSS/pull/2373 The refactoring required a call to init() even for static functions, which is most of the time not done. Removed premature abstraction of `$_SERVER`, which was the root cause of the bug. https://github.com/FreshRSS/FreshRSS/issues/2748#issuecomment-569898931 * Refactoring: Move serverIsPublic to Minz_Request * Add mitigations for wrong configurations Due to the regression, we have some existing configurations with a bad base_url * Forgot one instance --- lib/lib_rss.php | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'lib/lib_rss.php') diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 1060ef5c5..972f650bd 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -118,36 +118,6 @@ function escapeToUnicodeAlternative($text, $extended = true) { return trim(str_replace($problem, $replace, $text)); } -/** - * Test if a given server address is publicly accessible. - * - * Note: for the moment it tests only if address is corresponding to a - * localhost address. - * - * @param $address the address to test, can be an IP or a URL. - * @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( - 'localhost', - 'localhost.localdomain', - '[::1]', - 'ip6-localhost', - 'localhost6', - 'localhost6.localdomain6', - )); - - if ($is_public) { - $is_public &= !preg_match('/^(10|127|172[.]16|192[.]168)[.]/', $host); - $is_public &= !preg_match('/^(\[)?(::1$|fc00::|fe80::)/i', $host); - } - - return (bool)$is_public; -} - function format_number($n, $precision = 0) { // number_format does not seem to be Unicode-compatible return str_replace(' ', ' ', //Espace fine insécable -- cgit v1.2.3