mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 15:47:00 +02:00
Fix importing multiple SQL files not terminated by semicolon
Inspired by adminneo-org/adminneo#1c08e86.
This commit is contained in:
@@ -728,9 +728,10 @@ function pagination($page, $current) {
|
|||||||
/** Get file contents from $_FILES
|
/** Get file contents from $_FILES
|
||||||
* @param string
|
* @param string
|
||||||
* @param bool
|
* @param bool
|
||||||
|
* @param string
|
||||||
* @return mixed int for error, string otherwise
|
* @return mixed int for error, string otherwise
|
||||||
*/
|
*/
|
||||||
function get_file($key, $decompress = false) {
|
function get_file($key, $decompress = false, $delimiter = "") {
|
||||||
$file = $_FILES[$key];
|
$file = $_FILES[$key];
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
return null;
|
return null;
|
||||||
@@ -752,17 +753,17 @@ function get_file($key, $decompress = false) {
|
|||||||
); //! may not be reachable because of open_basedir
|
); //! may not be reachable because of open_basedir
|
||||||
if ($decompress) {
|
if ($decompress) {
|
||||||
$start = substr($content, 0, 3);
|
$start = substr($content, 0, 3);
|
||||||
if (function_exists("iconv") && preg_match("~^\xFE\xFF|^\xFF\xFE~", $start, $regs)) { // not ternary operator to save memory
|
if (function_exists("iconv") && preg_match("~^\xFE\xFF|^\xFF\xFE~", $start)) { // not ternary operator to save memory
|
||||||
$content = iconv("utf-16", "utf-8", $content);
|
$content = iconv("utf-16", "utf-8", $content);
|
||||||
} elseif ($start == "\xEF\xBB\xBF") { // UTF-8 BOM
|
} elseif ($start == "\xEF\xBB\xBF") { // UTF-8 BOM
|
||||||
$content = substr($content, 3);
|
$content = substr($content, 3);
|
||||||
}
|
}
|
||||||
$return .= $content . "\n\n";
|
}
|
||||||
} else {
|
$return .= $content;
|
||||||
$return .= $content;
|
if ($delimiter) {
|
||||||
|
$return .= (preg_match("($delimiter\\s*\$)", $content) ? "" : $delimiter) . "\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//! support SQL files not ending with semicolon
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ if (!$error && $_POST) {
|
|||||||
), "rb");
|
), "rb");
|
||||||
$query = ($fp ? fread($fp, 1e6) : false);
|
$query = ($fp ? fread($fp, 1e6) : false);
|
||||||
} else {
|
} else {
|
||||||
$query = get_file("sql_file", true);
|
$query = get_file("sql_file", true, ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($query)) { // get_file() returns error as number, fread() as false
|
if (is_string($query)) { // get_file() returns error as number, fread() as false
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
Adminer dev:
|
Adminer dev:
|
||||||
|
Fix importing multiple SQL files not terminated by semicolon
|
||||||
|
|
||||||
Adminer 5.0.2 (released 2025-03-10):
|
Adminer 5.0.2 (released 2025-03-10):
|
||||||
PostgreSQL: Fix setting NULL and original value on enum (bug #884)
|
PostgreSQL: Fix setting NULL and original value on enum (bug #884)
|
||||||
|
Reference in New Issue
Block a user