From 36c32393d930fdce3dd6e7ef9be81979ab4b15f8 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Thu, 18 Mar 2004 22:00:48 +0000 Subject: [PATCH] bug 906551 --- ChangeLog | 1 + libraries/sqlparser.lib.php | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c94e25b51..20be1a27d 100755 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ $Source$ 2004-03-18 Marc Delisle * lang/romanian: Updated, thanks to Valics Lehel. * libraries/common.lib.php: bug 913704, delete link in db search + * libraries/sqlparser.lib.php: bug 906551, GRANT...TO: another case 2004-03-13 Marc Delisle * sql.php: bug 913630: did not detect correctly DELETE FROM table diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index a120b96bb..481281cb3 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -450,6 +450,7 @@ if ($is_minimum_common == FALSE) { //TODO: a @ can also be present in expressions like // FROM 'user'@'%' + // or TO 'user'@'%' // in this case, the @ is wrongly marked as alpha_variable $is_sql_variable = ($c == '@'); @@ -1835,11 +1836,18 @@ if ($is_minimum_common == FALSE) { // // also we must not be inside a privilege list if ($i > 0) { - // the alpha_identifier condition is there to + // the alpha_identifier exception is there to // catch cases like // GRANT SELECT ON mydb.mytable TO myuser@localhost // (else, we get mydb.mytableTO ) - if (!$in_priv_list || $typearr[1] == 'alpha_identifier') { + // + // 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; } } else { @@ -1912,7 +1920,11 @@ if ($is_minimum_common == FALSE) { } break; case 'alpha_variable': - $after = ' '; + // other workaround for a problem similar to the one + // explained below for quote_single + if (!$in_priv_list) { + $after = ' '; + } break; case 'quote_double': case 'quote_single': @@ -1921,7 +1933,7 @@ if ($is_minimum_common == FALSE) { // the @ is incorrectly marked as alpha_variable // in the parser, and here, the '%' gets a blank before, // which is a syntax error - if ($typearr[1]!='alpha_variable') { + if ($typearr[1] !='alpha_variable') { $before .= ' '; } if ($infunction && $typearr[3] == 'punct_bracket_close_round') {