Merge pull request #15667 from mauriciofauth/whitelist-js
Remove js/whitelist.js
This commit is contained in:
commit
670f5babe9
@ -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
|
||||
);
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Exporting of Core::$goto_whitelist from PHP to Javascript
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\OutputBuffering;
|
||||
|
||||
if (! defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
if (! defined('TESTSUITE')) {
|
||||
chdir('..');
|
||||
|
||||
// Send correct type:
|
||||
header('Content-Type: text/javascript; charset=UTF-8');
|
||||
|
||||
// Cache output in client - the nocache query parameter makes sure that this
|
||||
// file is reloaded when config changes
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');
|
||||
|
||||
// Avoid loading the full common.inc.php because this would add many
|
||||
// non-js-compatible stuff like DOCTYPE
|
||||
define('PMA_MINIMUM_COMMON', true);
|
||||
define('PMA_PATH_TO_BASEDIR', '../');
|
||||
require_once ROOT_PATH . 'libraries/common.inc.php';
|
||||
// Close session early as we won't write anything there
|
||||
session_write_close();
|
||||
}
|
||||
|
||||
$buffer = OutputBuffering::getInstance();
|
||||
$buffer->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++;
|
||||
}
|
||||
@ -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;
|
||||
|
||||
@ -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');
|
||||
|
||||
@ -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,
|
||||
],
|
||||
|
||||
@ -56,10 +56,6 @@ class FilesTest extends TestCase
|
||||
public function listScripts()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'js/whitelist.php',
|
||||
'var GotoWhitelist',
|
||||
],
|
||||
[
|
||||
'js/messages.php',
|
||||
'var Messages = [];',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user