diff options
Diffstat (limited to 'include/network.php')
-rw-r--r-- | include/network.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/include/network.php b/include/network.php index 64605749d..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); @@ -1986,6 +1991,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 "," |