From 562c710eed67280923a528ba4ffabba54912556d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 25 Nov 2005 09:12:13 +0000 Subject: [PATCH] Do not create URLs like index.php?&. --- ChangeLog | 1 + libraries/auth/cookie.auth.lib.php | 38 ++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79c6d2e698..632a1d56fb 100755 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ $Source$ * */.cvsignore: Ignore custom headers and temporary files from Vim. * libraries/footer.inc.php, lang/*: Better message for new window, thanks to Sebastian and Marc. + * libraries/auth/cookie.auth.lib.php: Do not create URLs like index.php?&. 2005-11-24 Marc Delisle * js/querywindow.js: bug #1365503, "do not overwrite this query" diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php index b73cc65f1c..281963a07b 100644 --- a/libraries/auth/cookie.auth.lib.php +++ b/libraries/auth/cookie.auth.lib.php @@ -467,17 +467,45 @@ function PMA_auth_set_user() $GLOBALS['SERVER_SOFTWARE'] = $_SERVER['SERVER_SOFTWARE']; } } // end if - $redirect_url = $cfg['PmaAbsoluteUri'] . 'index.php?' - . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', - isset($GLOBALS['table']) ? $GLOBALS['table'] : '', '&') - . (!empty($GLOBALS['target']) ? '&target=' . urlencode($GLOBALS['target']) : '') - . '&' . SID; + + // URL where to go: + $redirect_url = $cfg['PmaAbsoluteUri'] . 'index.php'; + $separator = '?'; + + // any parameters to pass? + $params = PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', + isset($GLOBALS['table']) ? $GLOBALS['table'] : '', '&'); + if (!empty($params)) { + $redirect_url .= $separator . $params; + $separator = '&'; + } + unset($params); + + // any target to pass? + if (!empty($GLOBALS['target'])) { + $redirect_url .= $separator . 'target=' . urlencode($GLOBALS['target']). + $separator = '&'; + } + + // any seesion id to pass? + $sid = '' . SID; + if (!empty($sid)) { + $redirect_url .= $separator . $sid; + $separator = '&'; + } + unset($sid); + + // cleanup + unset($separtor); + + // And finally redirect if (!empty($GLOBALS['SERVER_SOFTWARE']) && $GLOBALS['SERVER_SOFTWARE'] == 'Microsoft-IIS/5.0') { header('Refresh: 0; url=' . $redirect_url); } else { header('Location: ' . $redirect_url); } + exit(); } // end if