Skip to content

Instantly share code, notes, and snippets.

@piotr-cz
Last active January 2, 2016 14:19

Revisions

  1. piotr-cz revised this gist Jan 8, 2014. 1 changed file with 26 additions and 10 deletions.
    36 changes: 26 additions & 10 deletions helper.php
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,31 @@
    /* JInstallerHelper::downloadPackage patch to encode url query values
    /**
    * 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);
    // Using JUri here (not parse_url) to preserve non-query data
    $uri = new JUri($url);

    // Get query variables
    $vars = $uri->getQuery(true);
    // Get query variables
    $vars = $uri->getQuery(true);

    // Encode values
    array_walk_recursive($vars, 'rawurlencode');
    // Encode values
    array_walk_recursive($vars, 'rawurlencode');

    // Set query and convert to string
    $uri->setQuery($vars);
    $url = (string) $uri;
    // Set query and convert to string
    $uri->setQuery($vars);
    $url = (string) $uri;

    // Rest of the code
    //...
    }
  2. piotr-cz created this gist Jan 8, 2014.
    15 changes: 15 additions & 0 deletions helper.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    /* 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;