HEX
Server: nginx/1.22.0
System: Linux iZuf6jdxbygmf6cco977lcZ 5.10.84-10.4.al8.x86_64 #1 SMP Tue Apr 12 12:31:07 CST 2022 x86_64
User: root (0)
PHP: 7.4.29
Disabled: passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen
Upload Files
File: /data/wwwroot/wordpress/phpMyAdmin/test/libraries/core/PMA_checkPageValidity_test.php
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Tests for PMA_checkPageValidity() from libraries/core.lib.php
 *
 * @package PhpMyAdmin-test
 */

/*
 * Include to test.
 */
require_once 'libraries/core.lib.php';

/**
 * Tests for PMA_checkPageValidity() from libraries/core.lib.php
 *
 * @package PhpMyAdmin-test
 */
class PMA_CheckPageValidity_Test extends PHPUnit_Framework_TestCase
{
    protected $goto_whitelist = array(
        'db_create.php',
        'db_datadict.php',
        'db_sql.php',
        'db_export.php',
        'db_search.php',
        'export.php',
        'import.php',
        'index.php',
        'pdf_pages.php',
        'pdf_schema.php',
        'server_binlog.php',
        'server_variables.php',
        'sql.php',
        'tbl_select.php',
        'transformation_overview.php',
        'transformation_wrapper.php',
        'user_password.php',
    );

    /**
     * Test for PMA_checkPageValidity
     *
     * @param string     $page      Page
     * @param array|null $whiteList White list
     * @param int        $expected  Expected value
     *
     * @return void
     *
     * @dataProvider provider
     */
    function testGotoNowhere($page, $whiteList, $expected)
    {
        $this->assertTrue($expected === PMA_checkPageValidity($page, $whiteList));
    }

    /**
     * Data provider for testGotoNowhere
     *
     * @return array
     */
    public function provider()
    {
        return array(
            array(null, null, false),
            array('export.php', $this->goto_whitelist, true),
            array('shell.php', $this->goto_whitelist, false),
            array('index.php?sql.php&test=true', $this->goto_whitelist, true),
            array('index.php%3Fsql.php%26test%3Dtrue', $this->goto_whitelist, true),
        );
    }
}