Last active
January 2, 2016 14:19
-
-
Save piotr-cz/8316210 to your computer and use it in GitHub Desktop.
Joomla-CMS: JInstallerHelper::downloadPackage patch to encode url query values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* JInstallerHelper::downloadPackage patch to encode redirect url query values. | |
* | |
* File Locations: | |
* - J3.2: /libraries/cms/installer/helper.php | |
* - J2.5: /libraries/joomla/installer/helper.php | |
* | |
* For performance reasons (assuming that initial $url is valid), | |
* this code can be moved just under the `302 == $response->code` check. | |
*/ | |
public static function downloadPackage($url, $target = false) | |
{ | |
/* JInstallerHelper::downloadPackage patch to encode url query values | |
*/ | |
// Using JUri here (not parse_url) to preserve non-query data | |
$uri = new JUri($url); | |
// Get query variables | |
$vars = $uri->getQuery(true); | |
// Encode values | |
array_walk_recursive($vars, 'rawurlencode'); | |
// Set query and convert to string | |
$uri->setQuery($vars); | |
$url = (string) $uri; | |
// Rest of the code | |
//... | |
} |
Yeah, at the very beginning of downloadPackage
method. Be warned, that I didn't test it at all.
To debug, see if this
if (strpos($url, 'https://s3.amazonaws.com/github-cloud/') === 0) { print_r($url); die('-') }}
is properly escaped.
The difference is that in 3.2 helper.php is located in libraries/cms/installer
and 2.5 in libraries/joomla/installer
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
which version is this? J3.x? My downloadPackage (libraries/joomla/installer/helper.php, right?) in 2.5.17 looks nothing like this. Or is it just to be inserted at the beginning of the method?