mirror of
https://github.com/vrana/adminer.git
synced 2025-08-14 10:34:01 +02:00
non-MySQL: Parse '--' without trailing space as comment in SQL command (fix #1025, regression from 5.2.0)
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
- Fix search anywhere (bug #1004, regression from 5.1.1)
|
- Fix search anywhere (bug #1004, regression from 5.1.1)
|
||||||
- Fix import without primary key (bug #1017, regression from 5.1.1)
|
- Fix import without primary key (bug #1017, regression from 5.1.1)
|
||||||
- PostgreSQL PDO: Fix bytea without primary key (bug #1021)
|
- PostgreSQL PDO: Fix bytea without primary key (bug #1021)
|
||||||
|
- non-MySQL: Parse '--' without trailing space as comment in SQL command (bug #1025, regression from 5.2.0)
|
||||||
|
|
||||||
## Adminer 5.2.0 (released 2025-04-08)
|
## Adminer 5.2.0 (released 2025-04-08)
|
||||||
- Autocomplete SQL commands
|
- Autocomplete SQL commands
|
||||||
|
@@ -20,6 +20,7 @@ if (!$error && $_POST["clear"]) {
|
|||||||
stop_session();
|
stop_session();
|
||||||
|
|
||||||
page_header((isset($_GET["import"]) ? lang('Import') : lang('SQL command')), $error);
|
page_header((isset($_GET["import"]) ? lang('Import') : lang('SQL command')), $error);
|
||||||
|
$line_comment = '--' . (JUSH == 'sql' ? ' ' : '');
|
||||||
|
|
||||||
if (!$error && $_POST) {
|
if (!$error && $_POST) {
|
||||||
$fp = false;
|
$fp = false;
|
||||||
@@ -51,7 +52,7 @@ if (!$error && $_POST) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$space = "(?:\\s|/\\*[\s\S]*?\\*/|(?:#|-- )[^\n]*\n?|--\r?\n)";
|
$space = "(?:\\s|/\\*[\s\S]*?\\*/|(?:#|$line_comment)[^\n]*\n?|--\r?\n)";
|
||||||
$delimiter = ";";
|
$delimiter = ";";
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$empty = true;
|
$empty = true;
|
||||||
@@ -64,7 +65,7 @@ if (!$error && $_POST) {
|
|||||||
}
|
}
|
||||||
$commands = 0;
|
$commands = 0;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$parse = '[\'"' . (JUSH == "sql" ? '`#' : (JUSH == "sqlite" ? '`[' : (JUSH == "mssql" ? '[' : ''))) . ']|/\*|--' . (JUSH == 'sql' ? ' ' : '') . '|$' . (JUSH == "pgsql" ? '|\$[^$]*\$' : '');
|
$parse = '[\'"' . (JUSH == "sql" ? '`#' : (JUSH == "sqlite" ? '`[' : (JUSH == "mssql" ? '[' : ''))) . ']|/\*|' . $line_comment . '|$' . (JUSH == "pgsql" ? '|\$[^$]*\$' : '');
|
||||||
$total_start = microtime(true);
|
$total_start = microtime(true);
|
||||||
$adminer_export = get_settings("adminer_import"); // this doesn't offer SQL export so we match the import/export style at select
|
$adminer_export = get_settings("adminer_import"); // this doesn't offer SQL export so we match the import/export style at select
|
||||||
$dump_format = adminer()->dumpFormat();
|
$dump_format = adminer()->dumpFormat();
|
||||||
@@ -94,7 +95,7 @@ if (!$error && $_POST) {
|
|||||||
$pattern =
|
$pattern =
|
||||||
($found == '/*' ? '\*/' :
|
($found == '/*' ? '\*/' :
|
||||||
($found == '[' ? ']' :
|
($found == '[' ? ']' :
|
||||||
(preg_match('~^-- |^#~', $found) ? "\n" :
|
(preg_match("~^$line_comment|^#~", $found) ? "\n" :
|
||||||
preg_quote($found) . ($c_style_escapes ? '|\\\\.' : ''))))
|
preg_quote($found) . ($c_style_escapes ? '|\\\\.' : ''))))
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -275,7 +276,7 @@ if (!isset($_GET["import"]) && $history) {
|
|||||||
list($q, $time, $elapsed) = $val;
|
list($q, $time, $elapsed) = $val;
|
||||||
echo '<a href="' . h(ME . "sql=&history=$key") . '">' . lang('Edit') . "</a>"
|
echo '<a href="' . h(ME . "sql=&history=$key") . '">' . lang('Edit') . "</a>"
|
||||||
. " <span class='time' title='" . @date('Y-m-d', $time) . "'>" . @date("H:i:s", $time) . "</span>" // @ - time zone may be not set
|
. " <span class='time' title='" . @date('Y-m-d', $time) . "'>" . @date("H:i:s", $time) . "</span>" // @ - time zone may be not set
|
||||||
. " <code class='jush-" . JUSH . "'>" . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace('~^(#|-- ).*~m', '', $q)))), 80, "</code>")
|
. " <code class='jush-" . JUSH . "'>" . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace("~^(#|$line_comment).*~m", '', $q)))), 80, "</code>")
|
||||||
. ($elapsed ? " <span class='time'>($elapsed)</span>" : "")
|
. ($elapsed ? " <span class='time'>($elapsed)</span>" : "")
|
||||||
. "<br>\n"
|
. "<br>\n"
|
||||||
;
|
;
|
||||||
|
Reference in New Issue
Block a user