From e74359fcfe4d97efe72a811b45526a69edae3893 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 11 Feb 2022 09:10:19 +0000 Subject: 3rd arg in str_replace() can not be null --- include/network.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/network.php') diff --git a/include/network.php b/include/network.php index 64605749d..044678a05 100644 --- a/include/network.php +++ b/include/network.php @@ -1986,6 +1986,10 @@ function getBestSupportedMimeType($mimeTypes = null, $acceptedTypes = false) { if($acceptedTypes === false) $acceptedTypes = $_SERVER['HTTP_ACCEPT']; + if (!$acceptedTypes) { + return null; + } + // Accept header is case insensitive, and whitespace isn’t important $accept = strtolower(str_replace(' ', '', $acceptedTypes)); // divide it into parts in the place of a "," -- cgit v1.2.3 From 139ffae3674e59307b46c67b0dcf77be9ec87b19 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 11 Feb 2022 09:51:21 +0000 Subject: fix another deprecation warning --- include/network.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include/network.php') diff --git a/include/network.php b/include/network.php index 044678a05..fa408e602 100644 --- a/include/network.php +++ b/include/network.php @@ -365,9 +365,14 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) { if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307 || $http_code == 308) { $matches = array(); preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches); - $newurl = trim(array_pop($matches)); - if(strpos($newurl,'/') === 0) + + $newurl = ''; + if (array_pop($matches)) + $newurl = trim(array_pop($matches)); + + if($newurl && strpos($newurl,'/') === 0) $newurl = $url . $newurl; + $url_parsed = @parse_url($newurl); if (isset($url_parsed)) { curl_close($ch); -- cgit v1.2.3 From b02f6a1dae3e3fae4af4b24e65256cdf653b2515 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 20 Mar 2022 14:35:25 +0100 Subject: Add function is_local_url() to check if url is local. --- include/network.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/network.php') diff --git a/include/network.php b/include/network.php index fa408e602..a236a6f8e 100644 --- a/include/network.php +++ b/include/network.php @@ -559,6 +559,14 @@ function z_dns_check($h,$check_mx = 0) { return((@dns_get_record($h,$opts) || filter_var($h, FILTER_VALIDATE_IP)) ? true : false); } +function is_local_url($url) { + if (str_starts_with($url, z_root()) || str_starts_with($url, '/')) { + return true; + } + + return false; +} + /** * @brief Validates a given URL. * -- cgit v1.2.3