Recent table: fix bug - not work for db or table name containing custom characters
This commit is contained in:
parent
ae1d967043
commit
376cc353dc
@ -199,9 +199,9 @@ $(document).ready(function(){
|
||||
/* Jump to recent table */
|
||||
$('#recentTable').change(function() {
|
||||
if (this.value != '') {
|
||||
var arr = this.value.split('.');
|
||||
window.parent.setDb(arr[0]);
|
||||
window.parent.setTable(arr[1]);
|
||||
var arr = jQuery.parseJSON(this.value);
|
||||
window.parent.setDb(arr['db']);
|
||||
window.parent.setTable(arr['table']);
|
||||
window.parent.refreshMain($('#LeftDefaultTabTable')[0].value);
|
||||
}
|
||||
});
|
||||
|
||||
@ -82,7 +82,7 @@ class PMA_RecentTable
|
||||
|
||||
$row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
|
||||
if (isset($row[0])) {
|
||||
return json_decode($row[0]);
|
||||
return json_decode($row[0], true);
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
@ -142,7 +142,8 @@ class PMA_RecentTable
|
||||
$html = '<option value="">(' . __('Recent tables') . ') ...</option>';
|
||||
if (count($this->tables)) {
|
||||
foreach ($this->tables as $table) {
|
||||
$html .= '<option value="' . htmlspecialchars($table) . '">' . htmlspecialchars($table) . '</option>';
|
||||
$html .= '<option value="' . htmlspecialchars(json_encode($table)) . '">' .
|
||||
htmlspecialchars('`' . $table['db'] . '`.`' . $table['table'] . '`') . '</option>';
|
||||
}
|
||||
} else {
|
||||
$html .= '<option value="">' . __('There are no recent tables') . '</option>';
|
||||
@ -159,7 +160,7 @@ class PMA_RecentTable
|
||||
{
|
||||
$html = '<input type="hidden" name="goto" id="LeftDefaultTabTable" value="' .
|
||||
htmlspecialchars($GLOBALS['cfg']['LeftDefaultTabTable']) . '" />';
|
||||
$html .= '<select name="table" id="recentTable">';
|
||||
$html .= '<select name="selected_recent_table" id="recentTable">';
|
||||
$html .= $this->getHtmlSelectOption();
|
||||
$html .= '</select>';
|
||||
|
||||
@ -176,12 +177,14 @@ class PMA_RecentTable
|
||||
*/
|
||||
public function add($db, $table)
|
||||
{
|
||||
$table_str = $db . '.' . $table;
|
||||
$table_arr = array();
|
||||
$table_arr['db'] = $db;
|
||||
$table_arr['table'] = $table;
|
||||
|
||||
// add only if this is new table
|
||||
if (! isset($this->tables[0]) || $this->tables[0] != $table_str) {
|
||||
array_unshift($this->tables, $table_str);
|
||||
$this->tables = array_merge(array_unique($this->tables));
|
||||
if (! isset($this->tables[0]) || $this->tables[0] != $table_arr) {
|
||||
array_unshift($this->tables, $table_arr);
|
||||
$this->tables = array_merge(array_unique($this->tables, SORT_REGULAR));
|
||||
$this->trim();
|
||||
if (isset($this->pma_table)) {
|
||||
return $this->saveToDb();
|
||||
|
||||
@ -510,21 +510,22 @@ if (PMA_isValid($_REQUEST['db'])) {
|
||||
*/
|
||||
$GLOBALS['table'] = '';
|
||||
if (PMA_isValid($_REQUEST['table'])) {
|
||||
// check if specified table contain db name
|
||||
if (strpos($_REQUEST['table'], '.')) {
|
||||
$splitted = explode('.', $_REQUEST['table']);
|
||||
if (count($splitted) == 2) { // make sure the format is "db.table"
|
||||
$GLOBALS['db'] = $splitted[0];
|
||||
$GLOBALS['url_params']['db'] = $GLOBALS['db'];
|
||||
$GLOBALS['table'] = $splitted[1];
|
||||
$GLOBALS['url_params']['table'] = $GLOBALS['table'];
|
||||
}
|
||||
} else {
|
||||
// can we strip tags from this?
|
||||
// only \ and / is not allowed in table names for MySQL
|
||||
$GLOBALS['table'] = $_REQUEST['table'];
|
||||
$GLOBALS['url_params']['table'] = $GLOBALS['table'];
|
||||
}
|
||||
// can we strip tags from this?
|
||||
// only \ and / is not allowed in table names for MySQL
|
||||
$GLOBALS['table'] = $_REQUEST['table'];
|
||||
$GLOBALS['url_params']['table'] = $GLOBALS['table'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Store currently selected recent table.
|
||||
* Affect $GLOBALS['db'] and $GLOBALS['table']
|
||||
*/
|
||||
if (PMA_isValid($_REQUEST['selected_recent_table'])) {
|
||||
$recent_table = json_decode($_REQUEST['selected_recent_table'], true);
|
||||
$GLOBALS['db'] = $recent_table['db'];
|
||||
$GLOBALS['url_params']['db'] = $GLOBALS['db'];
|
||||
$GLOBALS['table'] = $recent_table['table'];
|
||||
$GLOBALS['url_params']['table'] = $GLOBALS['table'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user