bug #1798786 [import] Wrong error message when a string contains semicolon

This commit is contained in:
Marc Delisle
2007-10-04 17:29:15 +00:00
parent 63ed2e0731
commit e2d2946a06
2 changed files with 25 additions and 16 deletions

View File

@@ -15,6 +15,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
- bug #1764195 [views] DROP button does not work on defective views - bug #1764195 [views] DROP button does not work on defective views
- bug #1805773 [relations] browse foreign values: return values not escaped, - bug #1805773 [relations] browse foreign values: return values not escaped,
thanks to Alex Rambau thanks to Alex Rambau
- bug #1798786 [import] Wrong error message when a string contains semicolon
2.11.1.0 (2007-09-20) 2.11.1.0 (2007-09-20)

View File

@@ -73,43 +73,51 @@ while (!($finished && $i >= $len) && !$error && !$timeout_passed) {
//while (($i < $len) && (strpos('\'";#-/', $buffer[$i]) === FALSE)) $i++; //while (($i < $len) && (strpos('\'";#-/', $buffer[$i]) === FALSE)) $i++;
//if ($i == $len) break; //if ($i == $len) break;
$oi = $i; $oi = $i;
$p1 = strpos($buffer, '\'', $i); $big_value = 2147483647;
if ($p1 === FALSE) { $first_quote = strpos($buffer, '\'', $i);
$p1 = 2147483647; if ($first_quote === FALSE) {
$first_quote = $big_value;
} else {
$next_quote = strpos($buffer, '\'', $first_quote + 1);
} }
$p2 = strpos($buffer, '"', $i); $p2 = strpos($buffer, '"', $i);
if ($p2 === FALSE) { if ($p2 === FALSE) {
$p2 = 2147483647; $p2 = $big_value;
} }
$p3 = strpos($buffer, $sql_delimiter, $i); /**
if ($p3 === FALSE) { * @todo it's a shortcoming to look for a delimiter that might be
$p3 = 2147483647; * inside quotes (or even double-quotes)
} else { * for the moment, catch the case of delimiter between quotes
*/
$first_sql_delimiter = strpos($buffer, $sql_delimiter, $i);
if ($first_sql_delimiter === FALSE) {
$first_sql_delimiter = $big_value;
} elseif ($first_sql_delimiter < $first_quote && $first_sql_delimiter > $next_quote) {
$found_delimiter = true; $found_delimiter = true;
} }
$p4 = strpos($buffer, '#', $i); $p4 = strpos($buffer, '#', $i);
if ($p4 === FALSE) { if ($p4 === FALSE) {
$p4 = 2147483647; $p4 = $big_value;
} }
$p5 = strpos($buffer, '--', $i); $p5 = strpos($buffer, '--', $i);
if ($p5 === FALSE || $p5 >= ($len - 2) || $buffer[$p5 + 2] > ' ') { if ($p5 === FALSE || $p5 >= ($len - 2) || $buffer[$p5 + 2] > ' ') {
$p5 = 2147483647; $p5 = $big_value;
} }
$p6 = strpos($buffer, '/*', $i); $p6 = strpos($buffer, '/*', $i);
if ($p6 === FALSE) { if ($p6 === FALSE) {
$p6 = 2147483647; $p6 = $big_value;
} }
$p7 = strpos($buffer, '`', $i); $p7 = strpos($buffer, '`', $i);
if ($p7 === FALSE) { if ($p7 === FALSE) {
$p7 = 2147483647; $p7 = $big_value;
} }
$p8 = strpos($buffer, 'DELIMITER', $i); $p8 = strpos($buffer, 'DELIMITER', $i);
if ($p8 === FALSE || $p8 >= ($len - 11) || $buffer[$p8 + 9] > ' ') { if ($p8 === FALSE || $p8 >= ($len - 11) || $buffer[$p8 + 9] > ' ') {
$p8 = 2147483647; $p8 = $big_value;
} }
$i = min ($p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8); $i = min ($first_quote, $p2, $first_sql_delimiter, $p4, $p5, $p6, $p7, $p8);
unset($p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8); unset($first_quote, $p2, $first_sql_delimiter, $p4, $p5, $p6, $p7, $p8);
if ($i == 2147483647) { if ($i == $big_value) {
$i = $oi; $i = $oi;
if (!$finished) { if (!$finished) {
break; break;