From 330e83d6dfe39ff7e890ee0077277e3e51f44d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 19 Oct 2004 12:59:45 +0000 Subject: [PATCH] Return raw query in case of error (bug #1048826). --- ChangeLog | 2 ++ libraries/sqlparser.lib.php | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b82f56a9..43846c670 100755 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ $Source$ * export.php: Use just \n for SQL exports (bug #1042521). * libraries/read_dump.lib.php: Set correct return value (bug #1048861). * sql.php: Fix undefined index. + * libraries/sqlparser.lib.php: Return raw query in case of error (bug + #1048826). 2004-10-17 Marc Delisle * lang/turkish update, thanks to boralioglu. diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index 18b364219..c40372126 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -1206,7 +1206,7 @@ if ($is_minimum_common == FALSE) { // ------------------------------------------------------- // This is a big hunk of debugging code by Marc for this. // ------------------------------------------------------- - /* + /* if (isset($current_select_expr)) { for ($trace=0; $trace<=$current_select_expr; $trace++) { echo "
"; @@ -1226,7 +1226,7 @@ if ($is_minimum_common == FALSE) { echo "table ref $trace $key => $val
\n"; } } - */ + */ // ------------------------------------------------------- @@ -1392,7 +1392,7 @@ if ($is_minimum_common == FALSE) { // do not add a blank after a function name - // TODO: can we combine loop 2 and loop 1? + // TODO: can we combine loop 2 and loop 1? // some code is repeated here... $sep=' '; @@ -1445,7 +1445,7 @@ if ($is_minimum_common == FALSE) { // FIXME: is it correct to always add $sep ? if (isset($subresult['queryflags']['select_from']) - && $subresult['queryflags']['select_from'] == 1 + && $subresult['queryflags']['select_from'] == 1 && !$seen_order) { $unsorted_query .= $arr[$i]['data'] . $sep; } @@ -1568,14 +1568,14 @@ if ($is_minimum_common == FALSE) { $foreign[$foreign_key_number]['ref_index_list'][] = $identifier; } else { // for MySQL 4.0.18, identifier is - // `table` or `db`.`table` + // `table` or `db`.`table` // first pass will pick the db name // next pass will execute the else and pick the // db name in $db_table[0] if ($arr[$i+1]['type'] == 'punct_qualifier') { $foreign[$foreign_key_number]['ref_db_name'] = $identifier; } else { - // for MySQL 4.0.16, identifier is + // for MySQL 4.0.16, identifier is // `table` or `db.table` $db_table = explode('.',$identifier); if (isset($db_table[1])) { @@ -1584,7 +1584,7 @@ if ($is_minimum_common == FALSE) { } else { $foreign[$foreign_key_number]['ref_table_name'] = $db_table[0]; } - } + } } } } @@ -1675,13 +1675,13 @@ if ($is_minimum_common == FALSE) { function PMA_SQP_formatHtml($arr, $mode='color', $start_token=0, $number_of_tokens=-1) { - // first check for the SQL parser having hit an error - if (PMA_SQP_isError()) { - return $arr; - } // then check for an array if (!is_array($arr)) { - return $arr; + return htmlspecialchars($arr); + } + // first check for the SQL parser having hit an error + if (PMA_SQP_isError()) { + return htmlspecialchars($arr['raw']); } // else do it properly switch ($mode) { @@ -1920,12 +1920,12 @@ if ($is_minimum_common == FALSE) { // GRANT SELECT ON mydb.mytable TO myuser@localhost // (else, we get mydb.mytableTO ) // - // the quote_single exception is there to + // the quote_single exception is there to // catch cases like // GRANT ... TO 'marc'@'domain.com' IDENTIFIED... // // TODO: fix all cases and find why this happens - + if (!$in_priv_list || $typearr[1] == 'alpha_identifier' || $typearr[1] == 'quote_single' || $typearr[1] == 'white_newline') { $before .= $space_alpha_reserved_word; }