Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed string constants and queries splitting. #490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions DOCKER.md
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 12 additions & 2 deletions adminer/sql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 "<p>$execute\n";
echo lang('Limit rows') . ": <input type='number' name='limit' class='size' value='" . h($_POST ? $_POST["limit"] : $_GET["limit"]) . "'>\n";

} else {
echo "<fieldset><legend>" . lang('File upload') . "</legend><div>";
$gz = (extension_loaded("zlib") ? "[.gz]" : "");
Expand Down