Bug #3196093 CSV import - Abort immediately and show error message on invalid parameters.
This commit is contained in:
@@ -56,10 +56,12 @@ $csv_enclosed = strtr($csv_enclosed, $replacements);
|
||||
$csv_escaped = strtr($csv_escaped, $replacements);
|
||||
$csv_new_line = strtr($csv_new_line, $replacements);
|
||||
|
||||
$param_error = FALSE;
|
||||
if (strlen($csv_terminated) != 1) {
|
||||
$message = PMA_Message::error(__('Invalid parameter for CSV import: %s'));
|
||||
$message->addParam(__('Columns terminated by'), false);
|
||||
$error = TRUE;
|
||||
$param_error = TRUE;
|
||||
// The default dialog of MS Excel when generating a CSV produces a
|
||||
// semi-colon-separated file with no chance of specifying the
|
||||
// enclosing character. Thus, users who want to import this file
|
||||
@@ -72,14 +74,22 @@ if (strlen($csv_terminated) != 1) {
|
||||
$message = PMA_Message::error(__('Invalid parameter for CSV import: %s'));
|
||||
$message->addParam(__('Columns enclosed by'), false);
|
||||
$error = TRUE;
|
||||
$param_error = TRUE;
|
||||
} elseif (strlen($csv_escaped) != 1) {
|
||||
$message = PMA_Message::error(__('Invalid parameter for CSV import: %s'));
|
||||
$message->addParam(__('Columns escaped by'), false);
|
||||
$error = TRUE;
|
||||
$param_error = TRUE;
|
||||
} elseif (strlen($csv_new_line) != 1 && $csv_new_line != 'auto') {
|
||||
$message = PMA_Message::error(__('Invalid parameter for CSV import: %s'));
|
||||
$message->addParam(__('Lines terminated by'), false);
|
||||
$error = TRUE;
|
||||
$param_error = TRUE;
|
||||
}
|
||||
|
||||
// If there is an error in the parameters entered, indicate that immediately.
|
||||
if ($param_error) {
|
||||
PMA_mysqlDie($message->getMessage(), '', '', $err_url);
|
||||
}
|
||||
|
||||
$buffer = '';
|
||||
|
Reference in New Issue
Block a user