[adminer-svn] SF.net SVN: adminer:[985] trunk
Database management in a single PHP file
Brought to you by:
jakubvrana
From: <jak...@us...> - 2009-08-20 14:43:07
|
Revision: 985 http://adminer.svn.sourceforge.net/adminer/?rev=985&view=rev Author: jakubvrana Date: 2009-08-20 14:43:01 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Fix long SQL query crash (bug #2839231) Use ungreedy regular expressions Modified Paths: -------------- trunk/adminer/select.inc.php trunk/adminer/sql.inc.php trunk/editor/include/adminer.inc.php Modified: trunk/adminer/select.inc.php =================================================================== --- trunk/adminer/select.inc.php 2009-08-20 14:04:24 UTC (rev 984) +++ trunk/adminer/select.inc.php 2009-08-20 14:43:01 UTC (rev 985) @@ -85,10 +85,10 @@ $file = preg_replace("~^\xEF\xBB\xBF~", '', $file); //! character set $cols = ""; $rows = array(); //! packet size - preg_match_all('~("[^"]*"|[^"\\n])+~', $file, $matches); + preg_match_all('~("[^"]*"|[^"\\n])+~U', $file, $matches); foreach ($matches[0] as $key => $val) { $row = array(); - preg_match_all('~(("[^"]*")+|[^,]*),~', "$val,", $matches2); + preg_match_all('~(("[^"]*")+|[^,]*),~U', "$val,", $matches2); if (!$key && !array_diff($matches2[1], array_keys($fields))) { //! doesn't work with column names containing ",\n // first row corresponds to column names - use it for table structure $cols = " (" . implode(", ", array_map('idf_escape', $matches2[1])) . ")"; Modified: trunk/adminer/sql.inc.php =================================================================== --- trunk/adminer/sql.inc.php 2009-08-20 14:04:24 UTC (rev 984) +++ trunk/adminer/sql.inc.php 2009-08-20 14:43:01 UTC (rev 985) @@ -31,7 +31,7 @@ } elseif (preg_match('(' . preg_quote($delimiter) . '|[\'`"]|/\\*|-- |#|$)', $query, $match, PREG_OFFSET_CAPTURE, $offset)) { if ($match[0][0] && $match[0][0] != $delimiter) { // is not end of a query - find closing part - $pattern = ($match[0][0] == "-- " || $match[0][0] == "#" ? '~.*~' : ($match[0][0] == "/*" ? '~.*\\*/~sU' : '~\\G([^\\\\' . $match[0][0] . ']|\\\\.)*(' . $match[0][0] . '|$)~s')); //! respect sql_mode NO_BACKSLASH_ESCAPES + $pattern = ($match[0][0] == "-- " || $match[0][0] == "#" ? '~.*~' : ($match[0][0] == "/*" ? '~.*\\*/~sU' : '~\\G([^\\\\' . $match[0][0] . ']|\\\\.)*(' . $match[0][0] . '|$)~sU')); //! respect sql_mode NO_BACKSLASH_ESCAPES preg_match($pattern, $query, $match, PREG_OFFSET_CAPTURE, $match[0][1] + 1); $offset = $match[0][1] + strlen($match[0][0]); } else { Modified: trunk/editor/include/adminer.inc.php =================================================================== --- trunk/editor/include/adminer.inc.php 2009-08-20 14:04:24 UTC (rev 984) +++ trunk/editor/include/adminer.inc.php 2009-08-20 14:43:01 UTC (rev 985) @@ -326,7 +326,7 @@ if ($function == "now") { return "$function()"; } - $return = $dbh->quote(ereg('date|timestamp', $field["type"]) && preg_match('(^' . preg_replace('~(\\\\\\$([0-9]))~', '(?P<p\\2>[0-9]+)', preg_quote(lang('$1-$3-$5'))) . '(.*))', $value, $match) + $return = $dbh->quote(ereg('date|timestamp', $field["type"]) && preg_match('(^' . preg_replace('~(\\\\\\$([0-9]))~', '(?P<p\\2>[0-9]+)', preg_quote(lang('$1-$3-$5'))) . '(.*))', $value, $match) //! {1,2} instead of + except year ? ($match["p1"] ? $match["p1"] : ($match["p2"] < 70 ? 20 : 19) . $match["p2"]) . "-$match[p3]$match[p4]-$match[p5]$match[p6]" . end($match) : $value ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |