]> git.joonet.de Git - adminer.git/commitdiff
non-MySQL: Parse '--' without trailing space as comment in SQL command (fix #1025...
authorJakub Vrana <jakub@vrana.cz>
Fri, 11 Apr 2025 20:15:06 +0000 (22:15 +0200)
committerJakub Vrana <jakub@vrana.cz>
Fri, 11 Apr 2025 20:15:14 +0000 (22:15 +0200)
CHANGELOG.md
adminer/sql.inc.php

index 4ce36b09515613d9b8cf702e2e95560e4bfe80b4..610a6066b3bcf24502d6265c07a57e4ce2c3c7a5 100644 (file)
@@ -2,6 +2,7 @@
 - Fix search anywhere (bug #1004, 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)
+- 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)
 - Autocomplete SQL commands
index ae2ff7ee05ceecf61a3ca97bafea365462e7fe44..ce349663ea1d0b8b0c04512c0ac1984fe1e24864 100644 (file)
@@ -20,6 +20,7 @@ if (!$error && $_POST["clear"]) {
 stop_session();
 
 page_header((isset($_GET["import"]) ? lang('Import') : lang('SQL command')), $error);
+$line_comment = '--' . (JUSH == 'sql' ? ' ' : '');
 
 if (!$error && $_POST) {
        $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 = ";";
                $offset = 0;
                $empty = true;
@@ -64,7 +65,7 @@ if (!$error && $_POST) {
                }
                $commands = 0;
                $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);
                $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();
@@ -94,7 +95,7 @@ if (!$error && $_POST) {
                                                $pattern =
                                                        ($found == '/*' ? '\*/' :
                                                        ($found == '[' ? ']' :
-                                                       (preg_match('~^-- |^#~', $found) ? "\n" :
+                                                       (preg_match("~^$line_comment|^#~", $found) ? "\n" :
                                                        preg_quote($found) . ($c_style_escapes ? '|\\\\.' : ''))))
                                                ;
 
@@ -275,7 +276,7 @@ if (!isset($_GET["import"]) && $history) {
                list($q, $time, $elapsed) = $val;
                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
-                       . " <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>" : "")
                        . "<br>\n"
                ;