I have searched on the trackers and did not find anything similar regarding this issue.
Currently, on the demo server, if you export a database/table in xml format, empty that database and import it back, sometimes the success message is shown as a PMA_Message::NOTICE ( in a div class="notice"), or no success message is shown at all. In both cases, the import is completed, but the page is redirected to index with ?target=main.php, instead of printing the success message on the import page (?target=db_import.php).
This behaviour is caused by the fact that the database name is escaped with PMA_backquote, called through several functions, and when the table is searched in the database, it is not found, so although the import succeeds, it is treated as database not found and redirected.
A little more details:
The problem starts with libraries/import/xml.php @line 309 which calls PMA_buildSQL() with the $db_name argument. In libraries/import.lib.php @lines 884 and 886 from PMA_buildSQL(), $sql is formed using PMA_backquote($db_name). $sql is then passed as an argument to PMA_importRunQuery @line 899, which is retained in the $import_run_buffer['sql'] @line 208. On the next call of PMA_importRunQuery(), the PMA_lookForUse() is used @line 166, with $import_run_buffer['sql'] as the first argument. There, preg_match is used to get all the non-spaces after USE in the $buffer @line 225, but next 2 rows -
$db = trim($match);
$db = trim($db, ';'); // for example, USE abc;
do not accomplish the job of getting the correct database name.
In order to get the correct database name, I added a PMA_removeBackquote($a_name) function, which does the exact opposite of PMA_backquote($a_name, $do_it = true). It unescapes backquotes ( from double backquotes to single backquotes) and removes backquotes on both sides of the unescaped database name. I declared it with only one argument, because the second one - $do_it - is not used in this context, and this context is currently the only place this function is used.
As a side note, I've noticed that PMA_lookForUse() receives 3 arguments, but the second one - @param string $db current db - is overwritten, so its value is never actually used.
I have tested this patch on a database called "`hg`'`'`'1`'"'""``"`'`"232j3jh`"````"`" importing database data from .xml, .sql, .csv and .ods exported files. The xml now correctly prints the success message on the import page, and the other import plugins` behaviour is not affected.
As another side note, the csv and csv excel import for databases do not keep the table names ( it replaces them with TABLE 1, and so on ). I don't know if that is the correct behaviour or if it is documented anywhere.
I have attached the patch containing the diff, and you can also find a separate branch regarding this on my repo.