From 094805dcbea063baf892a62b156646e6c1435bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 21 Apr 2006 07:55:12 +0000 Subject: [PATCH] Fix importing files without trailing new line (bug #1473944). --- ChangeLog | 4 ++++ libraries/import/csv.php | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33e4c17db..6d5ba9888 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2006-04-21 Michal Čihař + * libraries/import/csv.php: Fix importing files without trailing new line + (bug #1473944). + 2006-04-20 Michal Čihař * index.php: Check target against goto_whitelist. * libraries/url_generating.lib.php, libraries/session.inc.php, diff --git a/libraries/import/csv.php b/libraries/import/csv.php index ccaa2bf62..741eeceb4 100644 --- a/libraries/import/csv.php +++ b/libraries/import/csv.php @@ -191,13 +191,16 @@ if ($plugin_param == 'table') { } // Need to strip trailing enclosing char? if ($need_end && $ch == $csv_enclosed) { - if ($i == $len - 1) { + if ($finished && $i == $len - 1) { + $ch = NULL; + } elseif ($i == $len - 1) { $i = $fallbacki; $ch = $buffer[$i]; break; + } else { + $i++; + $ch = $buffer[$i]; } - $i++; - $ch = $buffer[$i]; } // Are we at the end? if ($ch == $csv_new_line || ($csv_new_line == 'auto' && ($ch == "\r" || $ch == "\n")) || ($finished && $i == $len - 1)) {