From 06d4b9c8db556dbe30451d245238daa26501fa36 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Tue, 10 Jul 2007 14:07:49 +0000 Subject: [PATCH] Allow '' in enum git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@100 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- call.inc.php | 2 +- create.inc.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/call.inc.php b/call.inc.php index f1f29e77..772802fa 100644 --- a/call.inc.php +++ b/call.inc.php @@ -5,7 +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 = '\'(?:[^\'\\\\]*|\\\\.)+\'|"(?:[^"\\\\]*|\\\\.)+"'; +$length = '\'(?:\'\'|[^\'\\\\]*|\\\\.)+\'|"(?:""|[^"\\\\]*|\\\\.)+"'; $pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]*|``)+)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(((?:[^'\")]*|$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); diff --git a/create.inc.php b/create.inc.php index f30eb96d..776401b5 100644 --- a/create.inc.php +++ b/create.inc.php @@ -23,11 +23,12 @@ 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"] ? "($field[length])" : "") + . ($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"])) . ")" : "") . (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->real_escape_string($field["collation"]) . "'" : "") . ($field["null"] ? "" : " NOT NULL")