diff --git a/_compile.php b/_compile.php
index 4193a35f..4c0be778 100644
--- a/_compile.php
+++ b/_compile.php
@@ -49,7 +49,7 @@ if ($_SESSION["lang"]) {
}
$file = preg_replace_callback('~(<\\?php)?\\s*(include|require)(_once)? "([^"]*)";(\\s*\\?>)?~', 'put_file', $file);
if ($_SESSION["lang"]) {
- $file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']*|\\\\.)+)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file);
+ $file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file);
$file = str_replace("\n", "", $file);
$file = str_replace("", $_SESSION["lang"], $file);
}
diff --git a/_lang.php b/_lang.php
index e3279d61..c928909f 100644
--- a/_lang.php
+++ b/_lang.php
@@ -7,7 +7,7 @@ if ($_SERVER["argc"] > 1) {
$messages_all = array();
foreach (glob("*.php") as $filename) {
$file = file_get_contents($filename);
- if (preg_match_all("~lang\\(('(?:[^\\\\']*|\\\\.)+')([),])~", $file, $matches)) {
+ if (preg_match_all("~lang\\(('(?:[^\\\\']+|\\\\.)*')([),])~", $file, $matches)) {
$messages_all += array_combine($matches[1], $matches[2]);
}
}
@@ -16,7 +16,7 @@ $file = file_get_contents("lang.inc.php");
preg_match_all("~\n\t\t'(.*)' => array\\(\n(.*\n)\t\t\\)~sU", $file, $translations, PREG_OFFSET_CAPTURE);
foreach (array_reverse($translations[2], true) as $key => $translation) {
$messages = $messages_all;
- preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']*|\\\\.)+') => .*[^,\n]),?~m", $translation[0], $matches, PREG_SET_ORDER);
+ preg_match_all("~^(\\s*)(?:// )?(('(?:[^\\\\']+|\\\\.)*') => .*[^,\n]),?~m", $translation[0], $matches, PREG_SET_ORDER);
$s = "";
foreach ($matches as $match) {
if (isset($messages[$match[3]])) {
diff --git a/call.inc.php b/call.inc.php
index 772802fa..34863c6d 100644
--- a/call.inc.php
+++ b/call.inc.php
@@ -5,8 +5,7 @@ function normalize_enum($match) {
return "'" . str_replace("'", "''", addcslashes(stripcslashes(str_replace($match[0]{0} . $match[0]{0}, $match[0]{0}, substr($match[0], 1, -1))), '\\')) . "'";
}
-$length = '\'(?:\'\'|[^\'\\\\]*|\\\\.)+\'|"(?:""|[^"\\\\]*|\\\\.)+"';
-$pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]*|``)+)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(((?:[^'\")]*|$length)+)\\))?\\s*(?:zerofill\\s+)?(unsigned)?";
+$pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]+|``)*)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(((?:[^'\")]*|$enum_length)+)\\))?\\s*(?:zerofill\\s+)?(unsigned)?";
$create = $mysql->result($mysql->query("SHOW CREATE " . (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE") . " " . idf_escape($_GET["call"])), 0, 2);
preg_match("~\\($pattern(?:\\s*,$pattern)*~is", $create, $match);
$in = array();
@@ -17,7 +16,7 @@ foreach ($matches as $i => $match) {
$field = array(
"field" => str_replace("``", "`", $match[2]) . $match[3],
"type" => $match[4], //! type aliases
- "length" => preg_replace_callback("~$length~s", 'normalize_enum', $match[5]),
+ "length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $match[5]),
"unsigned" => ($match[6] ? "unsigned" : ""), // zerofill ignored
"null" => true,
);
diff --git a/create.inc.php b/create.inc.php
index 9a0e7630..f9b07f03 100644
--- a/create.inc.php
+++ b/create.inc.php
@@ -23,12 +23,11 @@ if ($_POST && !$error && !$_POST["add"]) {
$fields = array();
ksort($_POST["fields"]);
$after = "FIRST";
- $length = '\'(?:\'\'|[^\'\\\\]*|\\\\.)+\'|"(?:""|[^"\\\\]*|\\\\.)+"';
foreach ($_POST["fields"] as $key => $field) {
if (strlen($field["field"]) && isset($types[$field["type"]])) {
$fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD "))
. idf_escape($field["field"]) . " $field[type]"
- . ($field["length"] ? "(" . (preg_match("~^\\s*(?:$length)(?:\\s*,\\s*(?:$length))*\\s*\$~", $field["length"]) && preg_match_all("~$length~", $field["length"], $matches) ? implode(",", $matches[0]) : intval($field["length"])) . ")" : "")
+ . ($field["length"] ? "(" . (preg_match("~^\\s*(?:$enum_length)(?:\\s*,\\s*(?:$enum_length))*\\s*\$~", $field["length"]) && preg_match_all("~$enum_length~", $field["length"], $matches) ? implode(",", $matches[0]) : intval($field["length"])) . ")" : "")
. (preg_match('~int|float|double|decimal~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " COLLATE '" . $mysql->escape_string($field["collation"]) . "'" : "")
. ($field["null"] ? "" : " NOT NULL")
diff --git a/database.inc.php b/database.inc.php
index d63a8f87..d3538e1e 100644
--- a/database.inc.php
+++ b/database.inc.php
@@ -2,12 +2,12 @@
if ($_POST && !$error) {
if ($_POST["drop"]) {
if ($mysql->query("DROP DATABASE " . idf_escape($_GET["db"]))) {
- redirect(substr(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF), 0, -1), lang('Database has been dropped.'));
+ redirect(substr(preg_replace('~db=[^&]*&~', '', $SELF), 0, -1), lang('Database has been dropped.'));
}
} elseif ($_GET["db"] !== $_POST["name"]) {
if ($mysql->query("CREATE DATABASE " . idf_escape($_POST["name"]) . ($_POST["collation"] ? " COLLATE '" . $mysql->escape_string($_POST["collation"]) . "'" : ""))) {
if (!strlen($_GET["db"])) {
- redirect(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been created.'));
+ redirect(preg_replace('~db=[^&]*&~', '', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been created.'));
}
$result = $mysql->query("SHOW TABLES");
while ($row = $result->fetch_row()) {
@@ -18,7 +18,7 @@ if ($_POST && !$error) {
$result->free();
if (!$row) {
$mysql->query("DROP DATABASE " . idf_escape($_GET["db"]));
- redirect(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'));
+ redirect(preg_replace('~db=[^&]*&~', '', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'));
}
}
} elseif (!$_POST["collation"] || $mysql->query("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE '" . $mysql->escape_string($_POST["collation"]) . "'")) {
diff --git a/functions.inc.php b/functions.inc.php
index 14b84759..56bd91ed 100644
--- a/functions.inc.php
+++ b/functions.inc.php
@@ -68,7 +68,7 @@ function indexes($table) {
function foreign_keys($table) {
global $mysql;
- static $pattern = '~`((?:[^`]*|``)+)`~';
+ static $pattern = '~`((?:[^`]+|``)*)`~';
$return = array();
$result = $mysql->query("SHOW CREATE TABLE " . idf_escape($table));
if ($result) {
@@ -255,7 +255,7 @@ function input($name, $field, $value) {
if (!isset($_GET["default"])) {
echo '';
}
- preg_match_all("~'((?:[^']*|'')+)'~", $field["length"], $matches);
+ preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
foreach ($matches[1] as $i => $val) {
$val = stripcslashes(str_replace("''", "'", $val));
$id = "field-$name-" . ($i+1);
@@ -267,7 +267,7 @@ function input($name, $field, $value) {
echo ' ';
}
} elseif ($field["type"] == "set") { //! 64 bits
- preg_match_all("~'((?:[^']*|'')+)'~", $field["length"], $matches);
+ preg_match_all("~'((?:[^']+|'')*)'~", $field["length"], $matches);
foreach ($matches[1] as $i => $val) {
$val = stripcslashes(str_replace("''", "'", $val));
$id = "field-$name-" . ($i+1);
diff --git a/index.php b/index.php
index c11dd0c1..84189e8d 100644
--- a/index.php
+++ b/index.php
@@ -28,6 +28,7 @@ if (isset($_GET["dump"])) {
$error = (in_array($_POST["token"], (array) $TOKENS) ? "" : lang('Invalid CSRF token. Send the form again.'));
}
$token = ($_POST && !$error ? $_POST["token"] : token());
+ $enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"';
if (isset($_GET["default"])) {
$_GET["edit"] = $_GET["default"];
}
diff --git a/sql.inc.php b/sql.inc.php
index c2e1f6c6..2bdc6655 100644
--- a/sql.inc.php
+++ b/sql.inc.php
@@ -13,7 +13,7 @@ if ($_POST && $error) {
$query = substr($query, strlen($match[0]));
} elseif (preg_match("~$delimiter|['`\"]|\$~", $query, $match, PREG_OFFSET_CAPTURE, $offset)) {
if ($match[0][0] && $match[0][0] != $delimiter) {
- preg_match('~\\G([^\\\\' . $match[0][0] . ']*|\\\\.)+(' . $match[0][0] . '|$)~s', $query, $match, PREG_OFFSET_CAPTURE, $match[0][1] + 1);
+ preg_match('~\\G([^\\\\' . $match[0][0] . ']+|\\\\.)*(' . $match[0][0] . '|$)~s', $query, $match, PREG_OFFSET_CAPTURE, $match[0][1] + 1);
$offset = $match[0][1] + strlen($match[0][0]);
} else {
$empty = false;