From 4a79e27e1098cc6ba6da52edb8baba8e04a3f5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 17 Dec 2019 21:09:54 -0300 Subject: [PATCH] Remove js/whitelist.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes the GotoWhitelist global. Signed-off-by: MaurĂ­cio Meneghini Fauth --- js/microhistory.js | 5 +--- js/whitelist.php | 50 ------------------------------------ libraries/classes/Core.php | 11 +------- libraries/classes/Header.php | 1 - test/classes/CoreTest.php | 16 +++++------- test/classes/FilesTest.php | 4 --- 6 files changed, 8 insertions(+), 79 deletions(-) delete mode 100644 js/whitelist.php diff --git a/js/microhistory.js b/js/microhistory.js index b25b39e7c2..502dc5f7f2 100644 --- a/js/microhistory.js +++ b/js/microhistory.js @@ -1,6 +1,3 @@ - -/* global GotoWhitelist */ // js/whitelist.php - /** * An implementation of a client-side page cache. * This object also uses the cache to provide a simple microhistory, @@ -294,7 +291,7 @@ MicroHistory.setUrlHash = (function (jQuery, window) { var questionMarkPosition = urlHash.indexOf('?'); if (colonPosition !== -1 && questionMarkPosition !== -1 && colonPosition < questionMarkPosition) { var hashUrl = urlHash.substring(colonPosition + 1, questionMarkPosition); - if (GotoWhitelist.indexOf(hashUrl) !== -1) { + if (hashUrl === 'index.php') { window.location = urlHash.substring( colonPosition + 1 ); diff --git a/js/whitelist.php b/js/whitelist.php deleted file mode 100644 index 0b351a7a39..0000000000 --- a/js/whitelist.php +++ /dev/null @@ -1,50 +0,0 @@ -start(); -if (! defined('TESTSUITE')) { - register_shutdown_function( - function () { - echo OutputBuffering::getInstance()->getContents(); - } - ); -} - -echo "var GotoWhitelist = [];\n"; -$i = 0; -foreach (Core::$goto_whitelist as $one_whitelist) { - echo 'GotoWhitelist[' , $i , '] = \'' , $one_whitelist , '\';' , "\n"; - $i++; -} diff --git a/libraries/classes/Core.php b/libraries/classes/Core.php index 7eb64c1a7a..56824e8709 100644 --- a/libraries/classes/Core.php +++ b/libraries/classes/Core.php @@ -20,15 +20,6 @@ use PhpMyAdmin\Display\Error as DisplayError; */ class Core { - /** - * the whitelist for goto parameter - * - * @static array $goto_whitelist - */ - public static $goto_whitelist = [ - 'index.php', - ]; - /** * checks given $var and returns it if valid, or $default of not valid * given $var is also checked for type being 'similar' as $default @@ -409,7 +400,7 @@ class Core public static function checkPageValidity(&$page, array $whitelist = [], $include = false): bool { if (empty($whitelist)) { - $whitelist = self::$goto_whitelist; + $whitelist = ['index.php']; } if (empty($page)) { return false; diff --git a/libraries/classes/Header.php b/libraries/classes/Header.php index 19ea0cf97c..60ca365dfb 100644 --- a/libraries/classes/Header.php +++ b/libraries/classes/Header.php @@ -171,7 +171,6 @@ class Header // Localised strings $this->_scripts->addFile('vendor/jquery/jquery.min.js'); $this->_scripts->addFile('vendor/jquery/jquery-migrate.js'); - $this->_scripts->addFile('whitelist.php'); $this->_scripts->addFile('vendor/sprintf.js'); $this->_scripts->addFile('ajax.js'); $this->_scripts->addFile('keyhandler.js'); diff --git a/test/classes/CoreTest.php b/test/classes/CoreTest.php index e7686bf401..6272f5e510 100644 --- a/test/classes/CoreTest.php +++ b/test/classes/CoreTest.php @@ -21,10 +21,6 @@ use stdClass; */ class CoreTest extends PmaTestCase { - protected $goto_whitelist = [ - 'index.php', - ]; - /** * Setup for test cases * @@ -326,37 +322,37 @@ class CoreTest extends PmaTestCase ], [ 'shell.php', - $this->goto_whitelist, + ['index.php'], false, false, ], [ 'shell.php', - $this->goto_whitelist, + ['index.php'], true, false, ], [ 'index.php?sql.php&test=true', - $this->goto_whitelist, + ['index.php'], false, true, ], [ 'index.php?sql.php&test=true', - $this->goto_whitelist, + ['index.php'], true, false, ], [ 'index.php%3Fsql.php%26test%3Dtrue', - $this->goto_whitelist, + ['index.php'], false, true, ], [ 'index.php%3Fsql.php%26test%3Dtrue', - $this->goto_whitelist, + ['index.php'], true, false, ], diff --git a/test/classes/FilesTest.php b/test/classes/FilesTest.php index 1c2538ed3a..32f2d88381 100644 --- a/test/classes/FilesTest.php +++ b/test/classes/FilesTest.php @@ -56,10 +56,6 @@ class FilesTest extends TestCase public function listScripts() { return [ - [ - 'js/whitelist.php', - 'var GotoWhitelist', - ], [ 'js/messages.php', 'var Messages = [];',