Skip to content

Commit

Permalink
Updater follows Location headers for valid archive filename (#12817)
Browse files Browse the repository at this point in the history
* made download() follow Location headers to resolve the valid filename of the update archive

* integrated suggestion of ggppdk, valid behavior if no query string

* strict type checking

* make Travis happy again... code style error
  • Loading branch information
milux authored and nvyush committed Nov 9, 2016
1 parent 262620d commit c583f65
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion administrator/components/com_joomlaupdate/models/default.php
Expand Up @@ -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();
Expand Down

0 comments on commit c583f65

Please sign in to comment.