Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Desportes <williamdes@wdes.fr>2021-04-23 19:32:45 +0300
committerWilliam Desportes <williamdes@wdes.fr>2021-04-23 19:46:05 +0300
commitd82e85f8527e3a5fcdf6465ccade115a7f80397c (patch)
treee5e58e1fd8bf79b90ecec2d7db863b78b91861ae /test/classes
parent2c22ff145aff791841ea4ed5fcdc15e3200046df (diff)
parent07bf86b483c73606f2b124dde8b24d15ccd55fca (diff)
Merge branch 'QA_5_1'
Signed-off-by: William Desportes <williamdes@wdes.fr>
Diffstat (limited to 'test/classes')
-rw-r--r--test/classes/Plugins/Export/ExportJsonTest.php47
-rw-r--r--test/classes/Stubs/DbiDummy.php16
2 files changed, 63 insertions, 0 deletions
diff --git a/test/classes/Plugins/Export/ExportJsonTest.php b/test/classes/Plugins/Export/ExportJsonTest.php
index 988fc5b716..6bed21d414 100644
--- a/test/classes/Plugins/Export/ExportJsonTest.php
+++ b/test/classes/Plugins/Export/ExportJsonTest.php
@@ -199,4 +199,51 @@ class ExportJsonTest extends AbstractTestCase
'SELECT * FROM `test_db`.`test_table`;'
));
}
+
+ public function testExportComplexData(): void
+ {
+ // normalString binaryField textField blobField
+ $this->expectOutputString(
+ '{"type":"table","name":"test_table_complex","database":"test_db","data":'
+ . "\n[\n"
+ . '{"f1":"\"\'\"><iframe onload=alert(1)>\u0448\u0435\u043b\u043b\u044b",'
+ . '"f2":"0x3078313233343638353766656665",'
+ . '"f3":"My awesome\nText","f4":"0x307861663132333466363863353766656665"},' . "\n"
+ . '{"f1":null,"f2":null,"f3":null,"f4":null},' . "\n"
+ . '{"f1":"","f2":"0x307831","f3":"\u0448\u0435\u043b\u043b\u044b","f4":"0x307832"}' . "\n"
+ . "]\n}\n"
+ );
+
+ $this->assertTrue(
+ $this->object->exportData(
+ 'test_db',
+ 'test_table_complex',
+ "\n",
+ 'example.com',
+ 'SELECT * FROM `test_db`.`test_table_complex`;'
+ )
+ );
+ }
+
+ public function testExportRawComplexData(): void
+ {
+ $this->expectOutputString(
+ '{"type":"raw","data":'
+ . "\n[\n"
+ . '{"f1":"\"\'\"><iframe onload=alert(1)>\u0448\u0435\u043b\u043b\u044b",'
+ . '"f2":"0x3078313233343638353766656665",'
+ . '"f3":"My awesome\nText","f4":"0x307861663132333466363863353766656665"},' . "\n"
+ . '{"f1":null,"f2":null,"f3":null,"f4":null},' . "\n"
+ . '{"f1":"","f2":"0x307831","f3":"\u0448\u0435\u043b\u043b\u044b","f4":"0x307832"}' . "\n"
+ . "]\n}\n"
+ );
+
+ $this->assertTrue(
+ $this->object->exportRawQuery(
+ 'example.com',
+ 'SELECT * FROM `test_db`.`test_table_complex`;',
+ "\n"
+ )
+ );
+ }
}
diff --git a/test/classes/Stubs/DbiDummy.php b/test/classes/Stubs/DbiDummy.php
index 97fe442425..3059d9f36a 100644
--- a/test/classes/Stubs/DbiDummy.php
+++ b/test/classes/Stubs/DbiDummy.php
@@ -22,6 +22,7 @@ use function preg_replace;
use function str_replace;
use function trim;
+use const MYSQLI_TYPE_BLOB;
use const MYSQLI_TYPE_DATETIME;
use const MYSQLI_TYPE_DECIMAL;
use const MYSQLI_TYPE_STRING;
@@ -2405,6 +2406,21 @@ class DbiDummy implements DbiExtension
],
],
[
+ 'query' => 'SELECT * FROM `test_db`.`test_table_complex`;',
+ 'columns' => ['f1', 'f2', 'f3', 'f4'],
+ 'result' => [
+ ['"\'"><iframe onload=alert(1)>шеллы', '0x12346857fefe', "My awesome\nText", '0xaf1234f68c57fefe'],
+ [null, null, null, null],
+ ['', '0x1', 'шеллы', '0x2'],
+ ],
+ 'metadata' => [
+ new FieldMetadata(MYSQLI_TYPE_STRING, 0, (object) ['charsetnr' => 33]),
+ new FieldMetadata(MYSQLI_TYPE_STRING, 0, (object) ['charsetnr' => 63]),
+ new FieldMetadata(MYSQLI_TYPE_BLOB, 0, (object) ['charsetnr' => 23]),
+ new FieldMetadata(MYSQLI_TYPE_BLOB, 0, (object) ['charsetnr' => 63]),
+ ],
+ ],
+ [
'query' => 'SHOW PROCEDURE STATUS;',
'columns' => ['Db', 'Name', 'Type'],
'result' => [