From 8c88abd05a3ec291a34015b6a455f0fa9786be39 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 16 Feb 2007 17:44:04 +0000 Subject: [PATCH] avoid generating big links after an upload into a BLOB --- ChangeLog | 4 ++++ libraries/common.lib.php | 27 +++++++++++++-------------- libraries/footer.inc.php | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index e89bc01dd..562cd0ec5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - ChangeLog $Id$ $HeadURL$ +2007-02-16 Marc Delisle + * libraries/common.lib.php, footer.inc.php: avoid generating big links + after an upload into a BLOB + 2007-02-14 Marc Delisle * libraries/common.lib.php: white page after uploading a 700 Kio BLOB * add a warning on main page if mcrypt can't be loaded (bug 1658160) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 13eb81552..65e7a05ec 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1433,13 +1433,18 @@ if (typeof(window.parent) != 'undefined' $query_base = $sql_query; } + $max_characters = 1000; + if (strlen($query_base) > $max_characters) { + define('PMA_QUERY_TOO_BIG',1); + } + // Parse SQL if needed if (isset($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) { $parsed_sql = $GLOBALS['parsed_sql']; } else { // when the query is large (for example an INSERT of binary // data), the parser chokes; so avoid parsing the query - if (strlen($query_base) < 1000) { + if (! defined('PMA_QUERY_TOO_BIG')) { $parsed_sql = PMA_SQP_parse($query_base); } } @@ -1481,20 +1486,13 @@ if (typeof(window.parent) != 'undefined' // Prepares links that may be displayed to edit/explain the query // (don't go to default pages, we must go to the page // where the query box is available) - // (also, I don't see why we should check the goto variable) - //if (!isset($GLOBALS['goto'])) { - //$edit_target = (isset($GLOBALS['table'])) ? $cfg['DefaultTabTable'] : $cfg['DefaultTabDatabase']; $edit_target = isset($GLOBALS['db']) ? (isset($GLOBALS['table']) ? 'tbl_sql.php' : 'db_sql.php') : 'server_sql.php'; - //} elseif ($GLOBALS['goto'] != 'main.php') { - // $edit_target = $GLOBALS['goto']; - //} else { - // $edit_target = ''; - //} if (isset($cfg['SQLQuery']['Edit']) && ($cfg['SQLQuery']['Edit'] == true) - && (!empty($edit_target))) { + && (!empty($edit_target)) + && ! defined('PMA_QUERY_TOO_BIG')) { if ($cfg['EditInWindow'] == true) { $onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($sql_query, false) . '\'); return false;'; @@ -1515,7 +1513,8 @@ if (typeof(window.parent) != 'undefined' // but only explain a SELECT (that has not been explained) /* SQL-Parser-Analyzer */ if (isset($cfg['SQLQuery']['Explain']) - && $cfg['SQLQuery']['Explain'] == true) { + && $cfg['SQLQuery']['Explain'] == true + && ! defined('PMA_QUERY_TOO_BIG')) { // Detect if we are validating as well // To preserve the validate uRL data @@ -1549,7 +1548,8 @@ if (typeof(window.parent) != 'undefined' // Also we would like to get the SQL formed in some nice // php-code (Mike Beck 2002-05-22) if (isset($cfg['SQLQuery']['ShowAsPHP']) - && $cfg['SQLQuery']['ShowAsPHP'] == true) { + && $cfg['SQLQuery']['ShowAsPHP'] == true + && ! defined('PMA_QUERY_TOO_BIG')) { $php_link = 'import.php' . $url_qpart . '&show_query=1' @@ -1622,8 +1622,7 @@ if (typeof(window.parent) != 'undefined' // when uploading a 700 Kio binary file into a LONGBLOB, // I get a white page, strlen($query_base) is 2 x 700 Kio // so put a hard limit here (let's say 1000) - $max_characters = 1000; - if (strlen($query_base) > $max_characters) { + if (defined('PMA_QUERY_TOO_BIG')) { echo ' ' . substr($query_base,0,$max_characters) . '[...]'; } else { echo ' ' . $query_base; diff --git a/libraries/footer.inc.php b/libraries/footer.inc.php index 73bb66032..36b778196 100644 --- a/libraries/footer.inc.php +++ b/libraries/footer.inc.php @@ -61,7 +61,7 @@ if (window.parent.refreshNavigation) { window.parent.reload_querywindow( '', '', - ''); + ''); }