From 52a832a97492e6359f31ca9e4235fb81820df10b Mon Sep 17 00:00:00 2001 From: Alexander Ivanov Date: Sun, 2 Jun 2024 12:54:09 +0300 Subject: [PATCH] Fixed string constants and queries splitting. Added Docker instructions. --- DOCKER.md | 31 +++++++++++++++++++++++++++++++ adminer/sql.inc.php | 14 ++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 DOCKER.md diff --git a/DOCKER.md b/DOCKER.md new file mode 100644 index 000000000..df04b60fb --- /dev/null +++ b/DOCKER.md @@ -0,0 +1,31 @@ +```shell +# Remove previous container +docker rm -f adminer-php-9999 + +# Start PHP 5.6 container +docker run \ + --log-driver local \ + --name adminer-php-9999 \ + --publish=9999:8000 \ + --volume ~/Documents/adminer:/usr/src/app \ + --workdir /usr/src/app \ + --detach \ + --interactive \ + --tty \ + php:5.6-alpine \ + php -S 0.0.0.0:8000 + +# Attach shell to PHP container +docker exec -it adminer-php-9999 /bin/sh + +# Connect PHP container to a network where DB is +docker network connect net adminer-php-9999 + +# Install PostgreSQL extensions for PHP +wget -O - https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions | sh -s pgsql pdo_pgsql + +# Restart PHP container +docker restart adminer-php-9999 +``` + +* [Adminer](http://localhost:9999/adminer) diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index 7a21235de..cb6635d6f 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -81,7 +81,17 @@ $offset = $pos + strlen($found); if ($found && rtrim($found) != $delimiter) { // find matching quote or comment end - while (preg_match('(' . ($found == '/*' ? '\*/' : ($found == '[' ? ']' : (preg_match('~^-- |^#~', $found) ? "\n" : preg_quote($found) . "|\\\\."))) . '|$)s', $query, $match, PREG_OFFSET_CAPTURE, $offset)) { //! respect sql_mode NO_BACKSLASH_ESCAPES + $c_style = $pos > 0 && substr($query, $pos - 1, 1) == 'E'; + $pattern = '(' . ( + $found == '/*' + ? '\*/' + : ($found == '[' + ? ']' + : (preg_match('~^-- |^#~', $found) + ? "\n" + : preg_quote($found) . "|\\\\" . ($c_style ? "." : "[^']"))) + ) . '|$)s'; + while (preg_match($pattern, $query, $match, PREG_OFFSET_CAPTURE, $offset)) { //! respect sql_mode NO_BACKSLASH_ESCAPES $s = $match[0][0]; if (!$s && $fp && !feof($fp)) { $query .= fread($fp, 1e5); @@ -225,7 +235,7 @@ echo script(($_POST ? "" : "qs('textarea').focus();\n") . "qs('#form').onsubmit = partial(sqlSubmit, qs('#form'), '" . js_escape(remove_from_uri("sql|limit|error_stops|only_errors|history")) . "');"); echo "

$execute\n"; echo lang('Limit rows') . ": \n"; - + } else { echo "

" . lang('File upload') . "
"; $gz = (extension_loaded("zlib") ? "[.gz]" : "");