mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/10321] Do not append the ? if the param-list is empty anyway.
PHPBB3-10321
This commit is contained in:
parent
1680b3a2a7
commit
dc149a43e4
2 changed files with 57 additions and 0 deletions
|
@ -2225,6 +2225,12 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
|
||||||
{
|
{
|
||||||
global $_SID, $_EXTRA_URL, $phpbb_hook;
|
global $_SID, $_EXTRA_URL, $phpbb_hook;
|
||||||
|
|
||||||
|
if ($params === '' || (is_array($params) && empty($params)))
|
||||||
|
{
|
||||||
|
// Do not append the ? if the param-list is empty anyway.
|
||||||
|
$params = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately.
|
// Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately.
|
||||||
// They could mimic most of what is within this function
|
// They could mimic most of what is within this function
|
||||||
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id))
|
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id))
|
||||||
|
|
51
tests/session/append_sid_test.php
Normal file
51
tests/session/append_sid_test.php
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2011 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||||
|
|
||||||
|
class phpbb_session_append_sid_test extends phpbb_test_case
|
||||||
|
{
|
||||||
|
|
||||||
|
public function append_sid_data()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('viewtopic.php?t=1&f=2', false, true, false, 'viewtopic.php?t=1&f=2'),
|
||||||
|
array('viewtopic.php', 't=1&f=2', true, false, 'viewtopic.php?t=1&f=2'),
|
||||||
|
array('viewtopic.php', 't=1&f=2', false, false, 'viewtopic.php?t=1&f=2'),
|
||||||
|
array('viewtopic.php', array('t' => 1, 'f' => 2), true, false, 'viewtopic.php?t=1&f=2'),
|
||||||
|
|
||||||
|
// Custom sid parameter
|
||||||
|
array('viewtopic.php', 't=1&f=2', true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid'),
|
||||||
|
|
||||||
|
// Testing anchors
|
||||||
|
array('viewtopic.php?t=1&f=2#anchor', false, true, false, 'viewtopic.php?t=1&f=2#anchor'),
|
||||||
|
array('viewtopic.php', 't=1&f=2#anchor', true, false, 'viewtopic.php?t=1&f=2#anchor'),
|
||||||
|
array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'viewtopic.php?t=1&f=2#anchor'),
|
||||||
|
|
||||||
|
// Anchors and custom sid
|
||||||
|
array('viewtopic.php?t=1&f=2#anchor', false, true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor'),
|
||||||
|
array('viewtopic.php', 't=1&f=2#anchor', true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor'),
|
||||||
|
array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor'),
|
||||||
|
|
||||||
|
// Empty parameters should not append the ?
|
||||||
|
array('viewtopic.php', false, true, false, 'viewtopic.php'),
|
||||||
|
array('viewtopic.php', '', true, false, 'viewtopic.php'),
|
||||||
|
array('viewtopic.php', array(), true, false, 'viewtopic.php'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider append_sid_data
|
||||||
|
*/
|
||||||
|
public function test_append_sid($url, $params, $is_amp, $session_id, $expected)
|
||||||
|
{
|
||||||
|
$this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue