From 12fb6cda18e1ae3d0985cd4a6b090d10ea128fb4 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Mon, 11 Nov 2002 18:26:41 +0000 Subject: [PATCH] bug 636575 --- ChangeLog | 1 + libraries/sqlparser.lib.php3 | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4ecc99145..3d9f5e60c 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ $Source$ 2002-11-11 Marc Delisle * libraries/sqlparser.lib.php3: LEFT JOIN ... USING + * libraries/sqlparser.lib.php3: bug 636575 (double quotes) 2002-11-10 Alexander M. Turek * lang/german-*.inc.php3: Fixed a typo. diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index 31d31e11a..8826c3d2c 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -592,7 +592,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { * not present (for example no select_expression alias). * * There is a debug section at the end of the main loop, if you want to - * witness the exact contents of select_expr and table_ref + * see the exact contents of select_expr and table_ref */ // must be sorted // TODO: current logic checks for only one word, so I put only the @@ -699,10 +699,20 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { // ============================== if (($arr[$i]['type'] == 'quote_backtick') + || ($arr[$i]['type'] == 'quote_double') || ($arr[$i]['type'] == 'alpha_identifier')) { - // remove backticks if any - $identifier = str_replace('`','',$arr[$i]['data']); + //TODO: check embedded double quotes or backticks? + // and/or remove just the first and last character? + if ($arr[$i]['type'] == 'quote_backtick') { + // remove backticks + $identifier = str_replace('`','',$arr[$i]['data']); + } + + if ($arr[$i]['type'] == 'quote_double') { + // remove double quotes + $identifier = str_replace('"','',$arr[$i]['data']); + } if ($subresult['querytype'] == 'SELECT') { if (!$seen_from) { @@ -729,7 +739,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { } // end if ($save_table_ref &&!$seen_end_of_table_ref) } // end if (!$seen_from) } // end if (querytype SELECT) - } // end if ( quote_backtick or alpha_identifier) + } // end if ( quote_backtick or double quote or alpha_identifier) // =================================== if ($arr[$i]['type'] == 'punct_qualifier') { @@ -873,6 +883,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { // set the $previous_was_identifier to FALSE if the current // token is not an identifier if (($arr[$i]['type'] != 'alpha_identifier') + && ($arr[$i]['type'] != 'quote_double') && ($arr[$i]['type'] != 'quote_backtick')) { $previous_was_identifier = FALSE; } // end if