|
-
+
{% trans 'Kill' %}
|
diff --git a/templates/setup/home/index.twig b/templates/setup/home/index.twig
index a289af7c8c..1642d60f1e 100644
--- a/templates/setup/home/index.twig
+++ b/templates/setup/home/index.twig
@@ -58,7 +58,7 @@
|
+ {{- get_common({ token: server.params.token }, '', false) }}">
{% trans 'Delete' %}
diff --git a/templates/sql/relational_column_dropdown.twig b/templates/sql/relational_column_dropdown.twig
index b77beaae34..b8498ddefd 100644
--- a/templates/sql/relational_column_dropdown.twig
+++ b/templates/sql/relational_column_dropdown.twig
@@ -1,4 +1,4 @@
{{ current_value }}
-
+
{% trans 'Browse foreign values' %}
diff --git a/templates/table/relation/foreign_key_row.twig b/templates/table/relation/foreign_key_row.twig
index 3df6c34550..cb1e996226 100644
--- a/templates/table/relation/foreign_key_row.twig
+++ b/templates/table/relation/foreign_key_row.twig
@@ -22,9 +22,8 @@
{% if one_key['constraint'] is defined %}
- {% set drop_url = 'sql.php' ~ get_common(this_params) %}
{% set drop_str = get_icon('b_drop', 'Drop'|trans) %}
- {{ link_or_button(drop_url, drop_str, {'class': 'drop_foreign_key_anchor ajax'}) }}
+ {{ link_or_button('sql.php', this_params, drop_str, {'class': 'drop_foreign_key_anchor ajax'}) }}
{% endif %}
diff --git a/templates/table/search/input_box.twig b/templates/table/search/input_box.twig
index a20fca3a9f..e711570005 100644
--- a/templates/table/search/input_box.twig
+++ b/templates/table/search/input_box.twig
@@ -21,7 +21,7 @@
value="{{ criteria_values[column_index] }}"
{% endif %}>
{{ titles['Browse']|replace({"'": "\\'"})|raw }}
@@ -34,10 +34,9 @@
class="textfield"
id="field_{{ column_index }}">
{% if in_fbs %}
- {% set edit_url = 'gis_data_editor.php' ~ get_common() %}
{% set edit_str = get_icon('b_edit', 'Edit/Insert'|trans) %}
- {{ link_or_button(edit_url, edit_str, [], '_blank') }}
+ {{ link_or_button('gis_data_editor.php', [], edit_str, [], '_blank') }}
{% endif %}
{% elseif column_type starts with 'enum'
diff --git a/templates/table/structure/display_partitions.twig b/templates/table/structure/display_partitions.twig
index b10a0bc929..5b3923b5ed 100644
--- a/templates/table/structure/display_partitions.twig
+++ b/templates/table/structure/display_partitions.twig
@@ -134,7 +134,7 @@
{% if partitions is empty %}
{% else %}
- {{ link_or_button(remove_url, 'Remove partitioning'|trans, {
+ {{ link_or_button('sql.php', remove_url_params, 'Remove partitioning'|trans, {
'class': 'button ajax',
'id': 'remove_partitioning'
}) }}
diff --git a/templates/table/structure/display_structure.twig b/templates/table/structure/display_structure.twig
index 16e11dbac2..19a416be44 100644
--- a/templates/table/structure/display_structure.twig
+++ b/templates/table/structure/display_structure.twig
@@ -372,9 +372,9 @@
{# Work on the table #}
{% if tbl_is_view and not db_is_system_schema %}
- {% set edit_view_url = 'view_create.php' ~ edit_view_url %}
{{ link_or_button(
- edit_view_url,
+ 'view_create.php',
+ {'db': db, 'table': table},
get_icon('b_edit', 'Edit view'|trans, true)
) }}
{% endif %}
@@ -481,7 +481,6 @@
} only %}
{% set remove_sql = 'ALTER TABLE ' ~ backquote(table) ~ ' REMOVE PARTITIONING' %}
- {% set remove_url = 'sql.php' ~ url_query ~ '&sql_query=' ~ remove_sql|url_encode %}
{% include 'table/structure/display_partitions.twig' with {
'db': db,
@@ -496,7 +495,7 @@
'sub_partition_expression': has_sub_partitions ? first_sub_partition.getExpression(),
'action_icons': action_icons,
'range_or_list': range_or_list,
- 'remove_url': remove_url
+ 'remove_url_params': url_params|merge({'sql_query': remove_sql})
} only %}
{% else %}
{% include 'table/structure/display_partitions.twig' with {
diff --git a/templates/table/tracking/main.twig b/templates/table/tracking/main.twig
index ff6c5c4214..5de9a98f21 100644
--- a/templates/table/tracking/main.twig
+++ b/templates/table/tracking/main.twig
@@ -60,7 +60,7 @@
{{- get_common(url_params|merge({
'version': version['version'],
'submit_delete_version': true
- }), '') }}">
+ }), '', false) }}">
{{ get_icon('b_drop', 'Delete version'|trans) }}
|
@@ -69,14 +69,14 @@
{{- get_common(url_params|merge({
'version': version['version'],
'report': 'true'
- }), '') }}">
+ }), '', false) }}">
{{ get_icon('b_report', 'Tracking report'|trans) }}
+ }), '', false) }}">
{{ get_icon('b_props', 'Structure snapshot'|trans) }}
diff --git a/test/classes/Config/PageSettingsTest.php b/test/classes/Config/PageSettingsTest.php
index 88cc755efa..b4d7f228f1 100644
--- a/test/classes/Config/PageSettingsTest.php
+++ b/test/classes/Config/PageSettingsTest.php
@@ -29,6 +29,7 @@ class PageSettingsTest extends PmaTestCase
{
$GLOBALS['PMA_Config'] = new Config();
$GLOBALS['PMA_Config']->enableBc();
+ $GLOBALS['PMA_Config']->set('URLQueryEncryption', false);
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = '';
diff --git a/test/classes/Controllers/Server/Status/ProcessesControllerTest.php b/test/classes/Controllers/Server/Status/ProcessesControllerTest.php
index 47d8da4826..f1b31b7cb1 100644
--- a/test/classes/Controllers/Server/Status/ProcessesControllerTest.php
+++ b/test/classes/Controllers/Server/Status/ProcessesControllerTest.php
@@ -250,7 +250,7 @@ class ProcessesControllerTest extends TestCase
]);
$killProcess = 'href="server_status_processes.php" data-post="'
- . Url::getCommon(['kill' => $process['Id']], '') . '"';
+ . Url::getCommon(['kill' => $process['Id']], '', false) . '"';
$this->assertStringContainsString(
$killProcess,
$html
diff --git a/test/classes/CoreTest.php b/test/classes/CoreTest.php
index 1eea188ffb..b74a64add0 100644
--- a/test/classes/CoreTest.php
+++ b/test/classes/CoreTest.php
@@ -13,6 +13,7 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\Core;
use PhpMyAdmin\Sanitize;
use PhpMyAdmin\Tests\PmaTestCase;
+use PhpMyAdmin\Url;
use stdClass;
/**
@@ -52,6 +53,7 @@ class CoreTest extends PmaTestCase
$GLOBALS['db'] = '';
$GLOBALS['table'] = '';
$GLOBALS['PMA_PHP_SELF'] = 'http://example.net/';
+ $GLOBALS['PMA_Config']->set('URLQueryEncryption', false);
}
/**
@@ -1537,4 +1539,61 @@ class CoreTest extends PmaTestCase
// Must work now, (good secret and blowfish_secret)
$this->assertTrue(Core::checkSqlQuerySignature($sqlQuery, $hmac));
}
+
+ /**
+ * @return void
+ */
+ public function testPopulateRequestWithEncryptedQueryParams()
+ {
+ global $PMA_Config;
+
+ $_SESSION = [];
+ $PMA_Config->set('URLQueryEncryption', true);
+ $PMA_Config->set('URLQueryEncryptionSecretKey', str_repeat('a', 32));
+
+ $_GET = ['pos' => '0', 'eq' => Url::encryptQuery('{"db":"test_db","table":"test_table"}')];
+ $_REQUEST = $_GET;
+
+ Core::populateRequestWithEncryptedQueryParams();
+
+ $expected = ['pos' => '0', 'db' => 'test_db', 'table' => 'test_table'];
+
+ $this->assertEquals($expected, $_GET);
+ $this->assertEquals($expected, $_REQUEST);
+ }
+
+ /**
+ * @return void
+ *
+ * @dataProvider providerForTestPopulateRequestWithEncryptedQueryParamsWithInvalidParam
+ */
+ public function testPopulateRequestWithEncryptedQueryParamsWithInvalidParam($encrypted, $decrypted)
+ {
+ global $PMA_Config;
+
+ $_SESSION = [];
+ $PMA_Config->set('URLQueryEncryption', true);
+ $PMA_Config->set('URLQueryEncryptionSecretKey', str_repeat('a', 32));
+
+ $_GET = $encrypted;
+ $_REQUEST = $encrypted;
+
+ Core::populateRequestWithEncryptedQueryParams();
+
+ $this->assertEquals($decrypted, $_GET);
+ $this->assertEquals($decrypted, $_REQUEST);
+ }
+
+ /**
+ * @return string[][][]
+ */
+ public function providerForTestPopulateRequestWithEncryptedQueryParamsWithInvalidParam()
+ {
+ return [
+ [[], []],
+ [['eq' => []], []],
+ [['eq' => ''], []],
+ [['eq' => 'invalid'], []],
+ ];
+ }
}
diff --git a/test/classes/Crypto/CryptoTest.php b/test/classes/Crypto/CryptoTest.php
new file mode 100644
index 0000000000..a73260d07b
--- /dev/null
+++ b/test/classes/Crypto/CryptoTest.php
@@ -0,0 +1,114 @@
+set('URLQueryEncryptionSecretKey', str_repeat('a', 32));
+
+ $cryptoWithSodium = new Crypto();
+ $encrypted = $cryptoWithSodium->encrypt('test');
+ $this->assertNotSame('test', $encrypted);
+ $this->assertSame('test', $cryptoWithSodium->decrypt($encrypted));
+ $this->assertArrayNotHasKey('URLQueryEncryptionSecretKey', $_SESSION);
+
+ $cryptoWithPhpseclib = new Crypto(true);
+ $encrypted = $cryptoWithPhpseclib->encrypt('test');
+ $this->assertNotSame('test', $encrypted);
+ $this->assertSame('test', $cryptoWithPhpseclib->decrypt($encrypted));
+ $this->assertArrayNotHasKey('URLQueryEncryptionSecretKey', $_SESSION);
+ }
+
+ /**
+ * @return void
+ */
+ public function testWithValidKeyFromSession()
+ {
+ global $PMA_Config;
+
+ $_SESSION = ['URLQueryEncryptionSecretKey' => str_repeat('a', 32)];
+ $PMA_Config->set('URLQueryEncryptionSecretKey', '');
+
+ $cryptoWithSodium = new Crypto();
+ $encrypted = $cryptoWithSodium->encrypt('test');
+ $this->assertNotSame('test', $encrypted);
+ $this->assertSame('test', $cryptoWithSodium->decrypt($encrypted));
+ $this->assertArrayHasKey('URLQueryEncryptionSecretKey', $_SESSION);
+
+ $cryptoWithPhpseclib = new Crypto(true);
+ $encrypted = $cryptoWithPhpseclib->encrypt('test');
+ $this->assertNotSame('test', $encrypted);
+ $this->assertSame('test', $cryptoWithPhpseclib->decrypt($encrypted));
+ $this->assertArrayHasKey('URLQueryEncryptionSecretKey', $_SESSION);
+ }
+
+ /**
+ * @return void
+ */
+ public function testWithNewSessionKey()
+ {
+ global $PMA_Config;
+
+ $_SESSION = [];
+ $PMA_Config->set('URLQueryEncryptionSecretKey', '');
+
+ $cryptoWithSodium = new Crypto();
+ $encrypted = $cryptoWithSodium->encrypt('test');
+ $this->assertNotSame('test', $encrypted);
+ $this->assertSame('test', $cryptoWithSodium->decrypt($encrypted));
+ $this->assertArrayHasKey('URLQueryEncryptionSecretKey', $_SESSION);
+ $this->assertEquals(32, mb_strlen($_SESSION['URLQueryEncryptionSecretKey'], '8bit'));
+
+ $cryptoWithPhpseclib = new Crypto(true);
+ $encrypted = $cryptoWithPhpseclib->encrypt('test');
+ $this->assertNotSame('test', $encrypted);
+ $this->assertSame('test', $cryptoWithPhpseclib->decrypt($encrypted));
+ $this->assertArrayHasKey('URLQueryEncryptionSecretKey', $_SESSION);
+ $this->assertEquals(32, mb_strlen($_SESSION['URLQueryEncryptionSecretKey'], '8bit'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testDecryptWithInvalidKey()
+ {
+ global $PMA_Config;
+
+ $_SESSION = [];
+ $PMA_Config->set('URLQueryEncryptionSecretKey', str_repeat('a', 32));
+
+ $cryptoWithSodium = new Crypto();
+ $encrypted = $cryptoWithSodium->encrypt('test');
+ $this->assertNotSame('test', $encrypted);
+ $this->assertSame('test', $cryptoWithSodium->decrypt($encrypted));
+
+ $PMA_Config->set('URLQueryEncryptionSecretKey', str_repeat('b', 32));
+
+ $cryptoWithSodium = new Crypto();
+ $this->assertNull($cryptoWithSodium->decrypt($encrypted));
+
+ $cryptoWithPhpseclib = new Crypto(true);
+ $encrypted = $cryptoWithPhpseclib->encrypt('test');
+ $this->assertNotSame('test', $encrypted);
+ $this->assertSame('test', $cryptoWithPhpseclib->decrypt($encrypted));
+
+ $PMA_Config->set('URLQueryEncryptionSecretKey', str_repeat('a', 32));
+
+ $cryptoWithPhpseclib = new Crypto(true);
+ $this->assertNull($cryptoWithPhpseclib->decrypt($encrypted));
+ }
+}
diff --git a/test/classes/DatabaseInterfaceTest.php b/test/classes/DatabaseInterfaceTest.php
index aeec9d7708..1d88a5c537 100644
--- a/test/classes/DatabaseInterfaceTest.php
+++ b/test/classes/DatabaseInterfaceTest.php
@@ -266,6 +266,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'host' => '',
'controluser' => 'u2',
'controlpass' => 'p2',
+ 'hide_connection_errors' => false,
];
$cfg_ssl = [
'user' => 'u',
@@ -274,6 +275,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'ssl' => true,
'controluser' => 'u2',
'controlpass' => 'p2',
+ 'hide_connection_errors' => false,
];
$cfg_control_ssl = [
'user' => 'u',
@@ -282,6 +284,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'control_ssl' => true,
'controluser' => 'u2',
'controlpass' => 'p2',
+ 'hide_connection_errors' => false,
];
return [
[
@@ -301,6 +304,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'compress' => false,
'controluser' => 'u2',
'controlpass' => 'p2',
+ 'hide_connection_errors' => false,
],
],
],
@@ -317,6 +321,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'port' => 0,
'ssl' => false,
'compress' => false,
+ 'hide_connection_errors' => false,
],
],
],
@@ -337,6 +342,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'compress' => false,
'controluser' => 'u2',
'controlpass' => 'p2',
+ 'hide_connection_errors' => false,
],
],
],
@@ -353,6 +359,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'port' => 0,
'ssl' => true,
'compress' => false,
+ 'hide_connection_errors' => false,
],
],
],
@@ -374,6 +381,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'controluser' => 'u2',
'controlpass' => 'p2',
'control_ssl' => true,
+ 'hide_connection_errors' => false,
],
],
],
@@ -390,6 +398,7 @@ class DatabaseInterfaceTest extends PmaTestCase
'port' => 0,
'ssl' => true,
'compress' => false,
+ 'hide_connection_errors' => false,
],
],
],
diff --git a/test/classes/Display/ResultsTest.php b/test/classes/Display/ResultsTest.php
index 1a8ea014d0..84424a41c7 100644
--- a/test/classes/Display/ResultsTest.php
+++ b/test/classes/Display/ResultsTest.php
@@ -46,6 +46,7 @@ class ResultsTest extends PmaTestCase
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$this->object = new DisplayResults('as', '', 0, '', '');
$GLOBALS['PMA_Config'] = new Config();
+ $GLOBALS['PMA_Config']->set('URLQueryEncryption', false);
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['text_dir'] = 'ltr';
$_SESSION[' HMAC_secret '] = 'test';
@@ -427,10 +428,16 @@ class ResultsTest extends PmaTestCase
{
return [
[
- 'tbl_change.php?db=Data&table=customer&where_clause=%60'
- . 'customer%60.%60id%60+%3D+1&clause_is_unique=1&sql_query='
- . 'SELECT+%2A+FROM+%60customer%60&goto=sql.php&default_'
- . 'action=update',
+ 'tbl_change.php',
+ [
+ 'db' => 'Data',
+ 'table' => 'customer',
+ 'where_clause' => '`customer`.`id` = 1',
+ 'clause_is_unique' => true,
+ 'sql_query' => 'SELECT * FROM `customer`',
+ 'goto' => 'sql.php',
+ 'default_action' => 'update',
+ ],
'klass edit_row_anchor',
'
Edit',
@@ -441,7 +448,7 @@ class ResultsTest extends PmaTestCase
. '
Edit'
. '
Copy',
'`customer`.`id` = 1',
'%60customer%60.%60id%60+%3D+1',
'klass',
- ''
. ' Copy'
. ' Delete',
'DELETE FROM `Data`.`customer` WHERE `customer`.`id` = 1',
@@ -584,10 +603,8 @@ class ResultsTest extends PmaTestCase
' | '
. ' '
. 'Delete'
@@ -612,6 +629,7 @@ class ResultsTest extends PmaTestCase
*/
public function testGetDeleteLink(
$del_url,
+ $delUrlParams,
$del_str,
$js_conf,
$class,
@@ -626,6 +644,7 @@ class ResultsTest extends PmaTestCase
'_getDeleteLink',
[
$del_url,
+ $delUrlParams,
$del_str,
$js_conf,
$class,
@@ -644,12 +663,7 @@ class ResultsTest extends PmaTestCase
return [
[
DisplayResults::POSITION_LEFT,
- 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data'
- . '%60.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show='
- . 'The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3D'
- . 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26'
- . 'message_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3D'
- . 'tbl_structure.php',
+ 'sql.php',
[
'edit_lnk' => 'ur',
'del_lnk' => 'dr',
@@ -665,12 +679,8 @@ class ResultsTest extends PmaTestCase
[
'`new`.`id`' => '= 1',
],
- 'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
- . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
- . 'FROM+%60new%60&goto=sql.php&default_action=update',
- 'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
- . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
- . 'FROM+%60new%60&goto=sql.php&default_action=insert',
+ 'tbl_change.php',
+ 'tbl_change.php',
'edit_row_anchor',
' Edit',
@@ -679,6 +689,21 @@ class ResultsTest extends PmaTestCase
' Delete',
'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
+ [
+ 'db' => 'data',
+ 'table' => 'new',
+ 'where_clause' => '`new`.`id` = 1',
+ 'clause_is_unique' => true,
+ 'sql_query' => 'SELECT * FROM `new`',
+ 'goto' => 'sql.php',
+ ],
+ [
+ 'db' => 'data',
+ 'table' => 'new',
+ 'sql_query' => 'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
+ 'message_to_show' => 'The row has been deleted.',
+ 'goto' => 'tbl_sql.php',
+ ],
' | '
+ . '_action=update&server=0&lang=en">'
. ' Edit'
. ' | | '
. ' Copy'
. ' | '
. ' '
. 'Delete'
@@ -716,12 +739,7 @@ class ResultsTest extends PmaTestCase
],
[
DisplayResults::POSITION_RIGHT,
- 'sql.php?db=data&table=new&sql_query=DELETE+FROM+%60data%60'
- . '.%60new%60+WHERE+%60new%60.%60id%60+%3D+1&message_to_show='
- . 'The+row+has+been+deleted&goto=sql.php%3Fdb%3Ddata%26table%3D'
- . 'new%26sql_query%3DSELECT%2B%252A%2BFROM%2B%2560new%2560%26message'
- . '_to_show%3DThe%2Brow%2Bhas%2Bbeen%2Bdeleted%26goto%3Dtbl_'
- . 'structure.php',
+ 'sql.php',
[
'edit_lnk' => 'ur',
'del_lnk' => 'dr',
@@ -737,12 +755,8 @@ class ResultsTest extends PmaTestCase
[
'`new`.`id`' => '= 1',
],
- 'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
- . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
- . 'FROM+%60new%60&goto=sql.php&default_action=update',
- 'tbl_change.php?db=data&table=new&where_clause=%60new%60.'
- . '%60id%60+%3D+1&clause_is_unique=1&sql_query=SELECT+%2A+'
- . 'FROM+%60new%60&goto=sql.php&default_action=insert',
+ 'tbl_change.php',
+ 'tbl_change.php',
'edit_row_anchor',
' Edit',
@@ -751,21 +765,34 @@ class ResultsTest extends PmaTestCase
' Delete',
'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
+ [
+ 'db' => 'data',
+ 'table' => 'new',
+ 'where_clause' => '`new`.`id` = 1',
+ 'clause_is_unique' => true,
+ 'sql_query' => 'SELECT * FROM `new`',
+ 'goto' => 'sql.php',
+ ],
+ [
+ 'db' => 'data',
+ 'table' => 'new',
+ 'sql_query' => 'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
+ 'message_to_show' => 'The row has been deleted.',
+ 'goto' => 'tbl_sql.php',
+ ],
' | '
. ' Delete'
. 'DELETE FROM `data`.`new` WHERE `new`.'
- . '`id` = 1 | '
+ . '`id` = 1 | '
. ' Copy'
. ' Edit'
. ' Edit',
@@ -821,6 +839,21 @@ class ResultsTest extends PmaTestCase
' Delete',
'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
+ [
+ 'db' => 'data',
+ 'table' => 'new',
+ 'where_clause' => '`new`.`id` = 1',
+ 'clause_is_unique' => true,
+ 'sql_query' => 'SELECT * FROM `new`',
+ 'goto' => 'sql.php',
+ ],
+ [
+ 'db' => 'data',
+ 'table' => 'new',
+ 'sql_query' => 'DELETE FROM `data`.`new` WHERE `new`.`id` = 1',
+ 'message_to_show' => 'The row has been deleted.',
+ 'goto' => 'tbl_sql.php',
+ ],
' | Delete',
null,
+ [],
+ [],
' | markTestSkipped('native setlocale failed');
+ }
+
+ _setlocale(LC_ALL, 'POSIX');
+
if (PHP_INT_SIZE === 8) {
$GLOBALS['cfg']['IconvExtraParams'] = '//TRANSLIT';
Encoding::setEngine(Encoding::ENGINE_ICONV);
diff --git a/test/classes/FooterTest.php b/test/classes/FooterTest.php
index 13c7018b04..fd505c55b8 100644
--- a/test/classes/FooterTest.php
+++ b/test/classes/FooterTest.php
@@ -48,6 +48,7 @@ class FooterTest extends PmaTestCase
$GLOBALS['table'] = '';
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_Config'] = new Config();
+ $GLOBALS['PMA_Config']->set('URLQueryEncryption', false);
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['Server']['verbose'] = 'verbose host';
diff --git a/test/classes/InsertEditTest.php b/test/classes/InsertEditTest.php
index c0076bddb5..6914fa80ae 100644
--- a/test/classes/InsertEditTest.php
+++ b/test/classes/InsertEditTest.php
@@ -65,6 +65,7 @@ class InsertEditTest extends TestCase
$GLOBALS['cfg']['LoginCookieValidity'] = 1440;
$GLOBALS['cfg']['enable_drag_drop_import'] = true;
$GLOBALS['PMA_Config'] = new Config();
+ $GLOBALS['PMA_Config']->set('URLQueryEncryption', false);
$this->insertEdit = new InsertEdit($GLOBALS['dbi']);
}
diff --git a/test/classes/Navigation/NavigationTreeTest.php b/test/classes/Navigation/NavigationTreeTest.php
index e1458cff05..60bb1ca318 100644
--- a/test/classes/Navigation/NavigationTreeTest.php
+++ b/test/classes/Navigation/NavigationTreeTest.php
@@ -13,6 +13,9 @@ use PhpMyAdmin\Config;
use PhpMyAdmin\Navigation\NavigationTree;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\PmaTestCase;
+use PhpMyAdmin\Theme;
+use PhpMyAdmin\Url;
+use ReflectionMethod;
/**
* Tests for PhpMyAdmin\Navigation\NavigationTree class
@@ -36,6 +39,7 @@ class NavigationTreeTest extends PmaTestCase
{
$GLOBALS['server'] = 1;
$GLOBALS['PMA_Config'] = new Config();
+ $GLOBALS['PMA_Config']->set('URLQueryEncryption', false);
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['cfg']['Server']['host'] = 'localhost';
$GLOBALS['cfg']['Server']['user'] = 'user';
@@ -96,4 +100,37 @@ class NavigationTreeTest extends PmaTestCase
$result = $this->object->renderDbSelect();
$this->assertStringContainsString('pma_navigation_select_database', $result);
}
+
+ /**
+ * @return void
+ */
+ public function testEncryptQueryParams()
+ {
+ global $PMA_Config;
+
+ $_SESSION = [];
+ $PMA_Config->set('URLQueryEncryption', false);
+ $PMA_Config->set('URLQueryEncryptionSecretKey', str_repeat('a', 32));
+
+ $method = new ReflectionMethod($this->object, 'encryptQueryParams');
+ $method->setAccessible(true);
+
+ $link = 'tbl_structure.php?server=1&db=test_db&table=test_table&pos=0';
+
+ $actual = $method->invoke($this->object, $link);
+ $this->assertEquals($link, $actual);
+
+ $PMA_Config->set('URLQueryEncryption', true);
+
+ $actual = $method->invoke($this->object, $link);
+ $this->assertStringStartsWith('tbl_structure.php?server=1&pos=0&eq=', $actual);
+
+ $url = parse_url($actual);
+ parse_str(htmlspecialchars_decode($url['query']), $query);
+
+ $this->assertRegExp('/^[a-zA-Z0-9-_=]+$/', $query['eq']);
+ $decrypted = Url::decryptQuery($query['eq']);
+ $this->assertJson($decrypted);
+ $this->assertSame('{"db":"test_db","table":"test_table"}', $decrypted);
+ }
}
diff --git a/test/classes/Plugins/Auth/AuthenticationCookieTest.php b/test/classes/Plugins/Auth/AuthenticationCookieTest.php
index 0af2e45cb1..73853d75d7 100644
--- a/test/classes/Plugins/Auth/AuthenticationCookieTest.php
+++ b/test/classes/Plugins/Auth/AuthenticationCookieTest.php
@@ -40,6 +40,7 @@ class AuthenticationCookieTest extends PmaTestCase
protected function setUp(): void
{
$GLOBALS['PMA_Config'] = new Config();
+ $GLOBALS['PMA_Config']->set('URLQueryEncryption', false);
$GLOBALS['PMA_Config']->enableBc();
$GLOBALS['server'] = 0;
$GLOBALS['text_dir'] = 'ltr';
diff --git a/test/classes/PmaTestCase.php b/test/classes/PmaTestCase.php
index a3b238a3ff..9f6eab36c0 100644
--- a/test/classes/PmaTestCase.php
+++ b/test/classes/PmaTestCase.php
@@ -40,6 +40,7 @@ class PmaTestCase extends TestCase
{
require ROOT_PATH . 'libraries/config.default.php';
$GLOBALS['cfg'] = $cfg;
+ $GLOBALS['PMA_Config']->set('URLQueryEncryption', false);
}
/**
diff --git a/test/classes/Server/UserGroupsTest.php b/test/classes/Server/UserGroupsTest.php
index d0bc43c4c3..a58255ff6a 100644
--- a/test/classes/Server/UserGroupsTest.php
+++ b/test/classes/Server/UserGroupsTest.php
@@ -131,7 +131,7 @@ class UserGroupsTest extends TestCase
'viewUsers' => 1,
'userGroup' => htmlspecialchars('usergroup'),
],
- ''
+ '', false
);
$this->assertStringContainsString(
$url_tag,
@@ -143,7 +143,7 @@ class UserGroupsTest extends TestCase
'editUserGroup' => 1,
'userGroup' => htmlspecialchars('usergroup'),
],
- ''
+ '', false
);
$this->assertStringContainsString(
$url_tag,
@@ -155,7 +155,7 @@ class UserGroupsTest extends TestCase
'deleteUserGroup' => 1,
'userGroup' => htmlspecialchars('usergroup'),
],
- ''
+ '', false
);
$this->assertStringContainsString(
$url_tag,
diff --git a/test/classes/UrlTest.php b/test/classes/UrlTest.php
index b1b0138b2c..9aed8438a4 100644
--- a/test/classes/UrlTest.php
+++ b/test/classes/UrlTest.php
@@ -29,6 +29,7 @@ class UrlTest extends TestCase
protected function setUp(): void
{
unset($_COOKIE['pma_lang']);
+ $GLOBALS['PMA_Config']->set('URLQueryEncryption', false);
}
/**
@@ -114,4 +115,61 @@ class UrlTest extends TestCase
$expected = '?server=x' . htmlentities($separator) . 'lang=en' ;
$this->assertEquals($expected, Url::getCommon());
}
+
+ /**
+ * @return void
+ */
+ public function testBuildHttpQueryWithUrlQueryEncryptionDisabled()
+ {
+ global $PMA_Config;
+
+ $PMA_Config->set('URLQueryEncryption', false);
+ $params = ['db' => 'test_db', 'table' => 'test_table', 'pos' => 0];
+ $this->assertEquals('db=test_db&table=test_table&pos=0', Url::buildHttpQuery($params));
+ }
+
+ /**
+ * @return void
+ */
+ public function testBuildHttpQueryWithUrlQueryEncryptionEnabled()
+ {
+ global $PMA_Config;
+
+ $_SESSION = [];
+ $PMA_Config->set('URLQueryEncryption', true);
+ $PMA_Config->set('URLQueryEncryptionSecretKey', str_repeat('a', 32));
+
+ $params = ['db' => 'test_db', 'table' => 'test_table', 'pos' => 0];
+ $query = Url::buildHttpQuery($params);
+ $this->assertStringStartsWith('pos=0&eq=', $query);
+ parse_str($query, $queryParams);
+ $this->assertCount(2, $queryParams);
+ $this->assertSame('0', $queryParams['pos']);
+ $this->assertTrue(is_string($queryParams['eq']));
+ $this->assertNotSame('', $queryParams['eq']);
+ $this->assertRegExp('/^[a-zA-Z0-9-_=]+$/', $queryParams['eq']);
+ $decrypted = Url::decryptQuery($queryParams['eq']);
+ $this->assertJson($decrypted);
+ $this->assertSame('{"db":"test_db","table":"test_table"}', $decrypted);
+ }
+
+ /**
+ * @return void
+ */
+ public function testQueryEncryption()
+ {
+ global $PMA_Config;
+
+ $_SESSION = [];
+ $PMA_Config->set('URLQueryEncryption', true);
+ $PMA_Config->set('URLQueryEncryptionSecretKey', str_repeat('a', 32));
+
+ $query = '{"db":"test_db","table":"test_table"}';
+ $encrypted = Url::encryptQuery($query);
+ $this->assertNotSame($query, $encrypted);
+ $this->assertNotSame('', $encrypted);
+ $this->assertRegExp('/^[a-zA-Z0-9-_=]+$/', $encrypted);
+ $decrypted = Url::decryptQuery($encrypted);
+ $this->assertSame($query, $decrypted);
+ }
}
diff --git a/test/classes/UtilTest.php b/test/classes/UtilTest.php
index f1b379d351..d5d06c9262 100644
--- a/test/classes/UtilTest.php
+++ b/test/classes/UtilTest.php
@@ -2700,38 +2700,22 @@ class UtilTest extends PmaTestCase
{
return [
[
- [
- 'index.php',
- 'text',
- ],
+ ['index.php', null, 'text'],
1000,
'text',
],
[
- [
- 'index.php?some=parameter',
- 'text',
- ],
+ ['index.php', ['some' => 'parameter'], 'text'],
20,
- 'text',
+ 'text',
],
[
- [
- 'index.php',
- 'text',
- [],
- 'target',
- ],
+ ['index.php', null, 'text', [], 'target'],
1000,
'text',
],
[
- [
- 'url.php?url=http://phpmyadmin.net/',
- 'text',
- [],
- '_blank',
- ],
+ ['url.php?url=http://phpmyadmin.net/', null, 'text', [], '_blank'],
1000,
'text',
],
|