diff --git a/libraries/Table.class.php b/libraries/Table.class.php index 9a15c48e53..83e67fd433 100644 --- a/libraries/Table.class.php +++ b/libraries/Table.class.php @@ -1240,8 +1240,8 @@ class PMA_Table $sql_query = " SELECT `prefs` FROM " . $pma_table . " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'" . - " AND `db_name` = '" . $this->db_name . "'" . - " AND `table_name` = '" . $this->name . "'"; + " AND `db_name` = '" . PMA_sqlAddSlashes($this->db_name) . "'" . + " AND `table_name` = '" . PMA_sqlAddSlashes($this->name) . "'"; $row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query)); if (isset($row[0])) { @@ -1264,8 +1264,9 @@ class PMA_Table $username = $GLOBALS['cfg']['Server']['user']; $sql_query = " REPLACE INTO " . $pma_table . - " VALUES ('" . $username . "', '" . $this->db_name . "', '" . - $this->name . "', '" . PMA_sqlAddSlashes(json_encode($this->uiprefs)) . "')"; + " VALUES ('" . $username . "', '" . PMA_sqlAddSlashes($this->db_name) . "', '" . + PMA_sqlAddSlashes($this->name) . "', '" . + PMA_sqlAddSlashes(json_encode($this->uiprefs)) . "')"; $success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']); diff --git a/libraries/export/codegen.php b/libraries/export/codegen.php index d60785c062..fb81cf9502 100644 --- a/libraries/export/codegen.php +++ b/libraries/export/codegen.php @@ -268,8 +268,8 @@ class TableProperty { $lines=array(); $lines[] = ""; - $lines[] = ""; - $lines[] = " "; + $lines[] = ""; + $lines[] = " "; $result = PMA_DBI_query(sprintf("DESC %s.%s", PMA_backquote($db), PMA_backquote($table))); if ($result) { diff --git a/libraries/export/htmlword.php b/libraries/export/htmlword.php index c840e932f6..e662cfb52d 100644 --- a/libraries/export/htmlword.php +++ b/libraries/export/htmlword.php @@ -75,7 +75,7 @@ xmlns="http://www.w3.org/TR/REC-html40"> * @access public */ function PMA_exportDBHeader($db) { - return PMA_exportOutputHandler('

' . __('Database') . ' ' . $db . '

'); + return PMA_exportOutputHandler('

' . __('Database') . ' ' . htmlspecialchars($db) . '

'); } /** @@ -118,7 +118,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { global $what; - if (! PMA_exportOutputHandler('

' . __('Dumping data for table') . ' ' . $table . '

')) { + if (! PMA_exportOutputHandler('

' . __('Dumping data for table') . ' ' . htmlspecialchars($table) . '

')) { return false; } if (! PMA_exportOutputHandler('')) { @@ -192,7 +192,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals { global $cfgRelation; - if (! PMA_exportOutputHandler('

' . __('Table structure for table') . ' ' .$table . '

')) { + if (! PMA_exportOutputHandler('

' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '

')) { return false; } @@ -313,8 +313,6 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals if ($row['Null'] != 'NO') { $row['Default'] = 'NULL'; } - } else { - $row['Default'] = $row['Default']; } $fmt_pre = ''; diff --git a/libraries/export/json.php b/libraries/export/json.php index 86e2e89d31..989ef888a4 100644 --- a/libraries/export/json.php +++ b/libraries/export/json.php @@ -74,7 +74,7 @@ function PMA_exportHeader() */ function PMA_exportDBHeader($db) { - PMA_exportOutputHandler('/* Database \'' . $db . '\' */ ' . $GLOBALS['crlf'] ); + PMA_exportOutputHandler('// Database \'' . $db . '\'' . $GLOBALS['crlf'] ); return true; } @@ -134,7 +134,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) // Output table name as comment if this is the first record of the table if ($record_cnt == 1) { - $buffer .= '/* ' . $db . '.' . $table . ' */' . $crlf . $crlf; + $buffer .= '// ' . $db . '.' . $table . $crlf . $crlf; $buffer .= '[{'; } else { $buffer .= ', {'; @@ -147,18 +147,20 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) $column = $columns[$i]; if (is_null($record[$i])) { - $buffer .= '"' . $column . '": null' . (! $isLastLine ? ',' : ''); + $buffer .= '"' . addslashes($column) . '": null' . (! $isLastLine ? ',' : ''); } elseif (is_numeric($record[$i])) { - $buffer .= '"' . $column . '": ' . $record[$i] . (! $isLastLine ? ',' : ''); + $buffer .= '"' . addslashes($column) . '": ' . $record[$i] . (! $isLastLine ? ',' : ''); } else { - $buffer .= '"' . $column . '": "' . addslashes($record[$i]) . '"' . (! $isLastLine ? ',' : ''); + $buffer .= '"' . addslashes($column) . '": "' . addslashes($record[$i]) . '"' . (! $isLastLine ? ',' : ''); } } $buffer .= '}'; } - $buffer .= ']'; + if ($record_cnt) { + $buffer .= ']'; + } if (! PMA_exportOutputHandler($buffer)) { return false; } diff --git a/libraries/export/xml.php b/libraries/export/xml.php index 85bab5f77f..cfa07f597a 100644 --- a/libraries/export/xml.php +++ b/libraries/export/xml.php @@ -105,7 +105,7 @@ function PMA_exportHeader() { $head .= '' . $crlf; if ($export_struct) { - $result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = \''.$db.'\' LIMIT 1'); + $result = PMA_DBI_fetch_result('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME` FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME` = \''.PMA_sqlAddSlashes($db).'\' LIMIT 1'); $db_collation = $result[0]['DEFAULT_COLLATION_NAME']; $db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];