]> git.joonet.de Git - adminer.git/commitdiff
Normalize enum and set
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 9 Jul 2007 23:13:34 +0000 (23:13 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 9 Jul 2007 23:13:34 +0000 (23:13 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@93 7c3ca157-0c34-0410-bff1-cbf682f78f5c

call.inc.php

index 653de71df2d55319e9aecca66d213aa37e04a2a1..9e206c9e9d004a9e8e7ca220cad598160aa56a2b 100644 (file)
@@ -1,6 +1,9 @@
 <?php
-$length = '(?:[^\'")]*|\'(?:[^\\\\\']*|\\.)+\'|"(?:[^\\\\\"]*|\\.)+")+';
-$pattern = "\\s*(IN|OUT|INOUT)?\\s*(?:`((?:[^`]*|``)+)`\\s*|\\b(\\S+)\\s+)([a-z]+)(?:\\s*\\(($length)\\))?\\s*(?:zerofill\\s+)?(unsigned)?";
+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)?";
 $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();
@@ -11,7 +14,7 @@ foreach ($matches as $i => $match) {
        $field = array(
                "field" => str_replace("``", "`", $match[2]) . $match[3],
                "type" => $match[4], //! type aliases
-               "length" => $match[5], //! replace \' by '', replace "" by ''
+               "length" => preg_replace_callback("~$length~s", 'normalize_enum', $match[5]),
                "unsigned" => ($match[6] ? "unsigned" : ""), // zerofill ignored
                "null" => true,
        );