Skip to content

Commit

Permalink
Preserve the query string on login's. Closes #2324
Browse files Browse the repository at this point in the history
  • Loading branch information
brendo committed Jan 19, 2015
1 parent cfffaf6 commit 4d18be1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions symphony/lib/core/class.administration.php
Expand Up @@ -190,6 +190,11 @@ private function __buildPage($page)
} else {
include_once(CONTENT . '/content.login.php');
$this->Page = new contentLogin;

// Include the query string for the login, RE: #2324
if ($queryString = $this->Page->__buildQueryString(['symphony-page', 'mode'], FILTER_SANITIZE_STRING)) {

This comment has been minimized.

Copy link
@nitriques

nitriques Jan 23, 2015

Member

@brendo Since when does passing a js array in php works ? This totally crashed my setup... Maybe because I still run php 5.3 ?

This comment has been minimized.

Copy link
@michael-e

michael-e Jan 23, 2015

Member

As of PHP 5.4 you can also use the short array syntax, which replaces array() with [].
http://php.net/manual/en/language.types.array.php

This comment has been minimized.

Copy link
@nitriques

nitriques Jan 23, 2015

Member

array('symphony-page', 'mode') seems to be working...

This comment has been minimized.

Copy link
@michael-e

michael-e Jan 23, 2015

Member

See above. If you have the time, please send a PR to fix this. (Requirement for Symphony still is PHP 5.3 and up.)

This comment has been minimized.

Copy link
@nitriques

nitriques Jan 23, 2015

Member

As of PHP 5.4

Ah did not knew that, thanks for the link. PR #2334

$page .= '?' . $queryString;
}
$this->Page->build(array('redirect' => $page));
}
} else {
Expand Down
15 changes: 12 additions & 3 deletions symphony/lib/toolkit/class.htmlpage.php
Expand Up @@ -283,16 +283,25 @@ public function addStylesheetToHead($path, $type = 'screen', $position = null, $

/**
* This function builds a HTTP query string from `$_GET` parameters with
* the option to remove parameters with an `$exclude` array
* the option to remove parameters with an `$exclude` array. Since Symphony 2.6.0
* it is also possible to override the default filters on the resulting string.
*
* @link http://php.net/manual/en/filter.filters.php
* @param array $exclude
* A simple array with the keys that should be omitted in the resulting
* query string.
* @param integer $filters
* The resulting query string is parsed through `filter_var`. By default
* the options are FILTER_FLAG_STRIP_LOW, FILTER_FLAG_STRIP_HIGH and
* FILTER_SANITIZE_STRING, but these can be overridden as desired.
* @return string
*/
public function __buildQueryString(array $exclude = array())
public function __buildQueryString(array $exclude = array(), $filters = null)
{
$exclude[] = 'page';
if (is_null($filters)) {
$filters = FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_SANITIZE_STRING;
}

// Generate the full query string and then parse it back to an array
$pre_exclusion = http_build_query($_GET, null, '&');
Expand All @@ -304,6 +313,6 @@ public function __buildQueryString(array $exclude = array())

$query = http_build_query($post_exclusion, null, '&');

return filter_var(urldecode($query), FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_SANITIZE_STRING);
return filter_var(urldecode($query), $filters);
}
}

0 comments on commit 4d18be1

Please sign in to comment.