From d578bda1009af54a8d32f11ba75f78aeddedb68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 19 Apr 2012 14:02:48 +0200 Subject: [PATCH 1/3] Clarify code for ForceSSL Conflicts: libraries/common.inc.php --- libraries/common.inc.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 82cdd22bdc..2309405d3b 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -75,7 +75,7 @@ if (version_compare(phpversion(), '5.3', 'lt')) { if (version_compare(phpversion(), '5.4', 'lt')) { /** * Avoid problems with magic_quotes_runtime - */ + */ @ini_set('magic_quotes_runtime', false); } @@ -335,11 +335,14 @@ if (isset($_COOKIE) * check HTTPS connection */ if ($GLOBALS['PMA_Config']->get('ForceSSL') - && !$GLOBALS['PMA_Config']->get('is_https')) { - PMA_sendHeaderLocation( - preg_replace('/^http/', 'https', - $GLOBALS['PMA_Config']->get('PmaAbsoluteUri')) - . PMA_generate_common_url($_GET, 'text')); + && ! $GLOBALS['PMA_Config']->get('is_https') +) { + // grab current URL + $url = $GLOBALS['PMA_Config']->get('PmaAbsoluteUri'); + // Replace http protocol + $url = preg_replace('@^http:@', 'https:', $url); + // Actually redirect + PMA_sendHeaderLocation($url . PMA_generate_common_url($_GET, 'text')); // delete the current session, otherwise we get problems (see bug #2397877) $GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']); exit; @@ -813,7 +816,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { $GLOBALS['PMA_Config']->setCookie('pma_lang', $GLOBALS['lang']); if (isset($GLOBALS['collation_connection'])) { $GLOBALS['PMA_Config']->setCookie( - 'pma_collation_connection', + 'pma_collation_connection', $GLOBALS['collation_connection']); } From 6fe86fc54919ac756bc5f0ee1229671259e1f490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 19 Apr 2012 14:06:47 +0200 Subject: [PATCH 2/3] More clever URL rewriting with ForceSSL (bug #3510196) --- libraries/common.inc.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 2309405d3b..72368b7e5d 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -339,8 +339,20 @@ if ($GLOBALS['PMA_Config']->get('ForceSSL') ) { // grab current URL $url = $GLOBALS['PMA_Config']->get('PmaAbsoluteUri'); - // Replace http protocol - $url = preg_replace('@^http:@', 'https:', $url); + // Parse current URL + $parsed = parse_url($url); + // In case parsing has failed do stupid string replacement + if ($parsed === false) { + // Replace http protocol + $url = preg_replace('@^http:@', 'https:', $url); + } else { + if($GLOBALS['PMA_Config']->get('SSLPort')) { + $port_number = $GLOBALS['PMA_Config']->get('SSLPort'); + } else { + $port_number = 443; + } + $url = 'https://' . $parsed['host'] . ':' . $port_number . '/' . $parsed['path']; + } // Actually redirect PMA_sendHeaderLocation($url . PMA_generate_common_url($_GET, 'text')); // delete the current session, otherwise we get problems (see bug #2397877) From 2e354b7b7551ac0c310bb05666b624936e103a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 20 Jun 2012 10:29:54 +0200 Subject: [PATCH 3/3] Document backport --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 06335dc854..cc62eb36ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ phpMyAdmin - ChangeLog - bug #3531586 [unterface] Add user form prints JSON when user presses enter - bug #3534121 [config] duplicate line in config.sample.inc.php - bug #3534311 [interface] Grid editing incorrectly parses ENUM/SET values +- bug #3510196 [core] More clever URL rewriting with ForceSSL 3.5.1.0 (2012-05-03) - bug #3510784 [edit] Limit clause ignored when sort order is remembered