diff --git a/ChangeLog b/ChangeLog index e1288ee7d6..85b66b893c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,8 @@ phpMyAdmin - ChangeLog - bug #3317293 [edit] Inline edit places HTML line breaks in edit area - bug #3319466 [interface] Inline query edit does not escape special characters - minor XSS (require a valid token) +- bug #3323060 [parser] SQL parser breaks AJAX requests if query has unclosed quotes +- bug #3323101 [parser] Invalid escape sequence in SQL parser 3.4.2.0 (2011-06-07) - bug #3301249 [interface] Iconic table operations does not remove inline edit label diff --git a/js/db_routines.js b/js/db_routines.js index 1c03b6b74b..95254ca064 100644 --- a/js/db_routines.js +++ b/js/db_routines.js @@ -246,7 +246,7 @@ $(document).ready(function() { if(data.success == true) { // Routine created successfully PMA_ajaxRemoveMessage($msg); - PMA_slidingMessage($('#js_query_display'), data.message); + PMA_slidingMessage(data.message); $ajaxDialog.dialog('close'); // If we are in 'edit' mode, we must remove the reference to the old row. if (mode == 'edit') { @@ -516,7 +516,7 @@ $(document).ready(function() { if(data.success == true) { // Routine executed successfully PMA_ajaxRemoveMessage($msg); - PMA_slidingMessage($('#js_query_display'), data.message); + PMA_slidingMessage(data.message); $ajaxDialog.dialog('close'); } else { PMA_ajaxShowMessage(data.error); @@ -542,7 +542,7 @@ $(document).ready(function() { $ajaxDialog.find('input[name^=params]').first().focus(); } else { // Routine executed successfully - PMA_slidingMessage($('#js_query_display'), data.message); + PMA_slidingMessage(data.message); } } else { PMA_ajaxShowMessage(data.error); diff --git a/js/functions.js b/js/functions.js index 3b4d9b4e54..c3900f33c4 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1300,7 +1300,7 @@ function PMA_ajaxShowMessage(message, timeout) { * Removes the message shown for an Ajax operation when it's completed */ function PMA_ajaxRemoveMessage($this_msgbox) { - if ($this_msgbox != 'undefined' && $this_msgbox instanceof jQuery) { + if ($this_msgbox != undefined && $this_msgbox instanceof jQuery) { $this_msgbox .stop(true, true) .fadeOut('medium'); @@ -2449,55 +2449,69 @@ $(document).ready(function() { /** * Creates a message inside an object with a sliding effect * + * @param msg A string containing the text to display * @param $obj a jQuery object containing the reference * to the element where to put the message - * @param msg A string containing the text to display + * This is optional, if no element is + * provided, one will be created below the + * navigation links at the top of the page * * @return bool True on success, false on failure */ -function PMA_slidingMessage($obj, msg) { - if ($obj != 'undefined' && $obj instanceof jQuery) { - if ($obj.has('div').length > 0) { - // If there already is a message inside the - // target object, we must get rid of it +function PMA_slidingMessage(msg, $obj) { + if (msg == undefined || msg.length == 0) { + // Don't show an empty message + return false; + } + if ($obj == undefined || ! $obj instanceof jQuery) { + // If the second argument was not supplied, + // we might have to create a new DOM node. + if ($('#PMA_slidingMessage').length == 0) { + $('#topmenucontainer') + .after(''); + } + $obj = $('#PMA_slidingMessage'); + } + if ($obj.has('div').length > 0) { + // If there already is a message inside the + // target object, we must get rid of it + $obj + .find('div') + .first() + .fadeOut(function () { + $obj + .children() + .remove(); $obj .append('
' + msg + '
') + .animate({ + height: $obj.find('div').first().height() + }) .find('div') .first() - .fadeOut(function () { - $(this).remove(); - $obj.animate({ - height: $obj.find('div').first().height() - }); + .fadeIn(); + }); + } else { + // Object does not already have a message + // inside it, so we simply slide it down + $obj + .width('100%') + .html('
' + msg + '
') + .find('div') + .first() + .slideDown(function() { + // Set the height of the parent + // to the height of the child + $obj + .height( $obj .find('div') .first() - .fadeIn(); - }); - } else { - // Object does not already have a message - // inside it, so we simply slide it down - $obj - .width('100%') - .html('
' + msg + '
') - .find('div') - .first() - .slideDown(function() { - // Set the height of the parent - // to the height of the child - $obj - .height( - $obj - .find('div') - .first() - .height() - ); - }); - } - return true; - } else { - return false; + .height() + ); + }); } + return true; } // end PMA_slidingMessage() /** @@ -2554,7 +2568,7 @@ $(document).ready(function() { } // Show the query that we just executed PMA_ajaxRemoveMessage($msg); - PMA_slidingMessage($('#js_query_display'), data.sql_query); + PMA_slidingMessage(data.sql_query); } else { PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error); } diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index 800588661f..3deaf3adcc 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -359,7 +359,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { $sql_array['raw'] = $sql; $pos = $pos_quote_separator; } - if (class_exists('PMA_Message')) { + if (class_exists('PMA_Message') && $GLOBALS['is_ajax_request'] != true) { PMA_Message::notice(__('Automatically appended backtick to the end of query!'))->display(); } } else { @@ -378,7 +378,7 @@ if (! defined('PMA_MINIMUM_COMMON')) { // Checks for MySQL escaping using a \ // And checks for ANSI escaping using the $quotetype character - if (($pos < $len) && PMA_STR_charIsEscaped($sql, $pos)) { + if (($pos < $len) && PMA_STR_charIsEscaped($sql, $pos) && $c != '`') { $pos ++; continue; } elseif (($pos + 1 < $len) && ($GLOBALS['PMA_substr']($sql, $pos, 1) == $quotetype) && ($GLOBALS['PMA_substr']($sql, $pos + 1, 1) == $quotetype)) {