correctly unquote identifiers
This commit is contained in:
@@ -18,6 +18,7 @@ $Source$
|
|||||||
- added PMA_unQuote() to remove quotes from strings
|
- added PMA_unQuote() to remove quotes from strings
|
||||||
* libraries/footer.inc.php: correctly escape strings inside JavaScript
|
* libraries/footer.inc.php: correctly escape strings inside JavaScript
|
||||||
(part of bug #1532721)
|
(part of bug #1532721)
|
||||||
|
* libraries/sqlparser.lib.php: correctly unquote identifiers
|
||||||
|
|
||||||
2006-08-01 Marc Delisle <lem9@users.sourceforge.net>
|
2006-08-01 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
* Documentation.html: patch #1532493 + light editing from me,
|
* Documentation.html: patch #1532493 + light editing from me,
|
||||||
|
@@ -601,29 +601,29 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
$t_suffix = '_functionName';
|
$t_suffix = '_functionName';
|
||||||
} elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_type, $PMA_SQPdata_column_type_cnt)) {
|
} elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_type, $PMA_SQPdata_column_type_cnt)) {
|
||||||
$t_suffix = '_columnType';
|
$t_suffix = '_columnType';
|
||||||
|
|
||||||
// Temporary fix for BUG #621357
|
// Temporary fix for BUG #621357
|
||||||
//TODO FIX PROPERLY NEEDS OVERHAUL OF SQL TOKENIZER
|
//TODO FIX PROPERLY NEEDS OVERHAUL OF SQL TOKENIZER
|
||||||
if ($d_cur_upper == 'SET' && $t_next != 'punct_bracket_open_round') {
|
if ($d_cur_upper == 'SET' && $t_next != 'punct_bracket_open_round') {
|
||||||
$t_suffix = '_reservedWord';
|
$t_suffix = '_reservedWord';
|
||||||
}
|
}
|
||||||
//END OF TEMPORARY FIX
|
//END OF TEMPORARY FIX
|
||||||
|
|
||||||
// CHARACTER is a synonym for CHAR, but can also be meant as
|
// CHARACTER is a synonym for CHAR, but can also be meant as
|
||||||
// CHARACTER SET. In this case, we have a reserved word.
|
// CHARACTER SET. In this case, we have a reserved word.
|
||||||
if ($d_cur_upper == 'CHARACTER' && $d_next_upper == 'SET') {
|
if ($d_cur_upper == 'CHARACTER' && $d_next_upper == 'SET') {
|
||||||
$t_suffix = '_reservedWord';
|
$t_suffix = '_reservedWord';
|
||||||
}
|
}
|
||||||
|
|
||||||
// experimental
|
// experimental
|
||||||
// current is a column type, so previous must not be
|
// current is a column type, so previous must not be
|
||||||
// a reserved word but an identifier
|
// a reserved word but an identifier
|
||||||
// CREATE TABLE SG_Persons (first varchar(64))
|
// CREATE TABLE SG_Persons (first varchar(64))
|
||||||
|
|
||||||
//if ($sql_array[$i-1]['type'] =='alpha_reservedWord') {
|
//if ($sql_array[$i-1]['type'] =='alpha_reservedWord') {
|
||||||
// $sql_array[$i-1]['type'] = 'alpha_identifier';
|
// $sql_array[$i-1]['type'] = 'alpha_identifier';
|
||||||
//}
|
//}
|
||||||
|
|
||||||
} elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_reserved_word, $PMA_SQPdata_reserved_word_cnt)) {
|
} elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_reserved_word, $PMA_SQPdata_reserved_word_cnt)) {
|
||||||
$t_suffix = '_reservedWord';
|
$t_suffix = '_reservedWord';
|
||||||
} elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_attrib, $PMA_SQPdata_column_attrib_cnt)) {
|
} elseif (PMA_STR_binarySearchInArr($d_cur_upper, $PMA_SQPdata_column_attrib, $PMA_SQPdata_column_attrib_cnt)) {
|
||||||
@@ -633,7 +633,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
if ($d_cur_upper == 'INNODB' && $d_prev_upper == 'SHOW' && $d_next_upper == 'STATUS') {
|
if ($d_cur_upper == 'INNODB' && $d_prev_upper == 'SHOW' && $d_next_upper == 'STATUS') {
|
||||||
$t_suffix = '_reservedWord';
|
$t_suffix = '_reservedWord';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($d_cur_upper == 'DEFAULT' && $d_next_upper == 'CHARACTER') {
|
if ($d_cur_upper == 'DEFAULT' && $d_next_upper == 'CHARACTER') {
|
||||||
$t_suffix = '_reservedWord';
|
$t_suffix = '_reservedWord';
|
||||||
}
|
}
|
||||||
@@ -1022,16 +1022,10 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
$identifier = $arr[$i]['data'];
|
$identifier = $arr[$i]['data'];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//TODO: check embedded double quotes or backticks?
|
|
||||||
// and/or remove just the first and last character?
|
|
||||||
case 'quote_backtick':
|
case 'quote_backtick':
|
||||||
$identifier = str_replace('`', '', $arr[$i]['data']);
|
|
||||||
break;
|
|
||||||
case 'quote_double':
|
case 'quote_double':
|
||||||
$identifier = str_replace('"', '', $arr[$i]['data']);
|
|
||||||
break;
|
|
||||||
case 'quote_single':
|
case 'quote_single':
|
||||||
$identifier = str_replace("'", "", $arr[$i]['data']);
|
$identifier = PMA_unQuote($arr[$i]['data']);
|
||||||
break;
|
break;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
@@ -1732,7 +1726,7 @@ if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {
|
|||||||
|
|
||||||
if ($arr[$i]['type'] == 'quote_backtick') {
|
if ($arr[$i]['type'] == 'quote_backtick') {
|
||||||
// remove backquotes
|
// remove backquotes
|
||||||
$identifier = str_replace('`', '', $arr[$i]['data']);
|
$identifier = PMA_unQuote($arr[$i]['data']);
|
||||||
} else {
|
} else {
|
||||||
$identifier = $arr[$i]['data'];
|
$identifier = $arr[$i]['data'];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user