diff --git a/administrator/components/com_joomlaupdate/models/default.php b/administrator/components/com_joomlaupdate/models/default.php index af91f0ee03fef..b3a2be07f9245 100644 --- a/administrator/components/com_joomlaupdate/models/default.php +++ b/administrator/components/com_joomlaupdate/models/default.php @@ -251,7 +251,20 @@ public function download() { $updateInfo = $this->getUpdateInformation(); $packageURL = $updateInfo['object']->downloadurl->_data; - $basename = basename($packageURL); + $headers = get_headers($packageURL, 1); + + // Follow the Location headers until the actual download URL is known + while (isset($headers['Location'])) + { + $packageURL = $headers['Location']; + $headers = get_headers($packageURL, 1); + } + // Remove protocol, path and query string from URL + $basename = basename($packageURL); + if (strpos($basename, '?') !== false) + { + $basename = substr($basename, 0, strpos($basename, '?')); + } // Find the path to the temp directory and the local package. $config = JFactory::getConfig();