From 2bf398a3a8d0627b88398384af246367cc1e00ba Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Wed, 5 Oct 2016 11:10:11 +0530 Subject: [PATCH 01/20] Use sprintf instead of directly concatenating the variable Signed-off-by: Deven Bansod --- templates/navigation/logo.phtml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/templates/navigation/logo.phtml b/templates/navigation/logo.phtml index c7e15614cb..5beda2be3e 100644 --- a/templates/navigation/logo.phtml +++ b/templates/navigation/logo.phtml @@ -17,12 +17,11 @@ $linkAttribs = isset($linkAttribs) ? $linkAttribs : null; if (!isset($logo)) { $logo = null; if (isset($GLOBALS['pmaThemeImage'])) { - $imgTag = ''; + $imgTag = ''; if (@file_exists($GLOBALS['pmaThemeImage'] . 'logo_left.png')) { - $logo = sprintf($imgTag, 'logo_left.png'); + $logo = sprintf($imgTag, $GLOBALS['pmaThemeImage'], 'logo_left.png'); } elseif (@file_exists($GLOBALS['pmaThemeImage'] . 'pma_logo2.png')) { - $logo = sprintf($imgTag, 'pma_logo2.png'); + $logo = sprintf($imgTag, $GLOBALS['pmaThemeImage'], 'pma_logo2.png'); } } } From 7bf85fe817114460de0ad51cf436d1921aef2924 Mon Sep 17 00:00:00 2001 From: Deven Bansod Date: Thu, 6 Oct 2016 10:27:23 +0530 Subject: [PATCH 02/20] Use sprintf instead of directly concatenating the variable Signed-off-by: Deven Bansod --- libraries/navigation/NavigationTree.php | 6 +++++- libraries/navigation/nodes/Node.php | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libraries/navigation/NavigationTree.php b/libraries/navigation/NavigationTree.php index 5bc830a34b..0e9b2986c0 100644 --- a/libraries/navigation/NavigationTree.php +++ b/libraries/navigation/NavigationTree.php @@ -171,10 +171,13 @@ class NavigationTree * @todo describe a scenario where this code is executed */ if (!$GLOBALS['cfg']['Server']['DisableIS']) { + $dbSeparator = Util::sqlAddSlashes( + $GLOBALS['cfg']['NavigationTreeDbSeparator'] + ); $query = "SELECT (COUNT(DB_first_level) DIV %d) * %d "; $query .= "from ( "; $query .= " SELECT distinct SUBSTRING_INDEX(SCHEMA_NAME, "; - $query .= " '" . Util::sqlAddSlashes($GLOBALS['cfg']['NavigationTreeDbSeparator']) . "', 1) "; + $query .= " '%s', 1) "; $query .= " DB_first_level "; $query .= " FROM INFORMATION_SCHEMA.SCHEMATA "; $query .= " WHERE `SCHEMA_NAME` < '%s' "; @@ -185,6 +188,7 @@ class NavigationTree $query, (int)$GLOBALS['cfg']['FirstLevelNavigationItems'], (int)$GLOBALS['cfg']['FirstLevelNavigationItems'], + $dbSeparator, Util::sqlAddSlashes($GLOBALS['db']) ) ); diff --git a/libraries/navigation/nodes/Node.php b/libraries/navigation/nodes/Node.php index de6b1d2d62..e78cf4debf 100644 --- a/libraries/navigation/nodes/Node.php +++ b/libraries/navigation/nodes/Node.php @@ -424,7 +424,9 @@ class Node return $retval; } - $dbSeparator = $GLOBALS['cfg']['NavigationTreeDbSeparator']; + $dbSeparator = Util::sqlAddSlashes( + $GLOBALS['cfg']['NavigationTreeDbSeparator'] + ); if (isset($GLOBALS['cfg']['Server']['DisableIS']) && !$GLOBALS['cfg']['Server']['DisableIS'] ) { @@ -434,7 +436,7 @@ class Node $query .= "SELECT DB_first_level "; $query .= "FROM ( "; $query .= "SELECT DISTINCT SUBSTRING_INDEX(SCHEMA_NAME, "; - $query .= "'" . Util::sqlAddSlashes($dbSeparator) . "', 1) "; + $query .= "'%s', 1) "; $query .= "DB_first_level "; $query .= "FROM INFORMATION_SCHEMA.SCHEMATA "; $query .= $this->_getWhereClause('SCHEMA_NAME', $searchClause); @@ -444,11 +446,19 @@ class Node $query .= ") t2 "; $query .= $this->_getWhereClause('SCHEMA_NAME', $searchClause); $query .= "AND 1 = LOCATE(CONCAT(DB_first_level, "; - $query .= "'" . Util::sqlAddSlashes($dbSeparator) . "'), "; + $query .= "'%s'), "; $query .= "CONCAT(SCHEMA_NAME, "; - $query .= "'" . Util::sqlAddSlashes($dbSeparator) . "')) "; + $query .= "'%s')) "; $query .= "ORDER BY SCHEMA_NAME ASC"; - $retval = $GLOBALS['dbi']->fetchResult($query); + + $retval = $GLOBALS['dbi']->fetchResult( + sprintf( + $query, + $dbSeparator, + $dbSeparator, + $dbSeparator + ) + ); return $retval; } From 96b4f13e54c9ebbebfd19d0690bfa0812b6818c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 8 Dec 2016 10:23:57 +0100 Subject: [PATCH 03/20] Quote table name for use in regexp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- libraries/controllers/database/DatabaseStructureController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/controllers/database/DatabaseStructureController.php b/libraries/controllers/database/DatabaseStructureController.php index cd22393f35..925ccd1244 100644 --- a/libraries/controllers/database/DatabaseStructureController.php +++ b/libraries/controllers/database/DatabaseStructureController.php @@ -887,7 +887,7 @@ class DatabaseStructureController extends DatabaseController if ($this->db == PMA_extractDbOrTable($db_table) && preg_match( "@^" . - mb_substr(PMA_extractDbOrTable($db_table, 'table'), 0, -1) . "@", + preg_quote(mb_substr(PMA_extractDbOrTable($db_table, 'table'), 0, -1)) . "@", $truename ) ) { From 4c84070ad6136c3158caa93286754ebbfbce61ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 8 Dec 2016 10:49:06 +0100 Subject: [PATCH 04/20] Avoid using REQUEST_URI in form action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's really not necessary here and might cause redirection issues. Signed-off-by: Michal Čihař --- setup/frames/index.inc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup/frames/index.inc.php b/setup/frames/index.inc.php index 370bf748a7..4d279d891c 100644 --- a/setup/frames/index.inc.php +++ b/setup/frames/index.inc.php @@ -91,8 +91,7 @@ if (!$is_https) { PMA_messagesSet('notice', 'no_https', __('Insecure connection'), $text); } -echo '
'; +echo ''; echo PMA_URL_getHiddenInputs(); echo '