diff --git a/ChangeLog b/ChangeLog index 5c107ae1c2..310bd1bb0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,9 @@ phpMyAdmin - ChangeLog - bug Fix popup message on build SQL of import - bug #3523499 [core] Make X-WebKit-CSP work better - replace Highcharts with jqplot for query profiling, zoom search +- bug #3531584 [interface] No form validation in change password dialog +- bug #3531585 [interface] Broken password validation in copy user form +- bug #3531586 [unterface] Add user form prints JSON when user presses enter 3.5.1.0 (2012-05-03) - bug #3510784 [edit] Limit clause ignored when sort order is remembered diff --git a/js/functions.js b/js/functions.js index 13ce2a0cef..1bb944544c 100644 --- a/js/functions.js +++ b/js/functions.js @@ -2387,6 +2387,47 @@ $(document).ready(function() { }) // end $().live() }) // end $(document).ready() for Create Database +/** + * Validates the password field in a form + * + * @see PMA_messages['strPasswordEmpty'] + * @see PMA_messages['strPasswordNotSame'] + * @param object the form + * @return boolean whether the field value is valid or not + */ +function checkPassword(the_form) +{ + // Did the user select 'no password'? + if (typeof(the_form.elements['nopass']) != 'undefined' + && the_form.elements['nopass'][0].checked) { + return true; + } else if (typeof(the_form.elements['pred_password']) != 'undefined' + && (the_form.elements['pred_password'].value == 'none' + || the_form.elements['pred_password'].value == 'keep')) { + return true; + } + + var password = the_form.elements['pma_pw']; + var password_repeat = the_form.elements['pma_pw2']; + var alert_msg = false; + + if (password.value == '') { + alert_msg = PMA_messages['strPasswordEmpty']; + } else if (password.value != password_repeat.value) { + alert_msg = PMA_messages['strPasswordNotSame']; + } + + if (alert_msg) { + alert(alert_msg); + password.value = ''; + password_repeat.value = ''; + password.focus(); + return false; + } + + return true; +} // end of the 'checkPassword()' function + /** * Attach Ajax event handlers for 'Change Password' on main.php */ @@ -2419,6 +2460,15 @@ $(document).ready(function() { }) .append(data); displayPasswordGenerateButton(); + + $('#change_password_form').bind('submit', function (e) { + e.preventDefault(); + $(this) + .closest('.ui-dialog') + .find('.ui-dialog-buttonpane .ui-button') + .first() + .click(); + }); }) // end $.get() }) // end handler for change password anchor @@ -2436,6 +2486,10 @@ $(document).ready(function() { */ var the_form = $("#change_password_form"); + if (! checkPassword(the_form[0])) { + return false; + } + /** * @var this_value String containing the value of the submit button. * Need to append this for the change password form on Server Privileges diff --git a/js/server_privileges.js b/js/server_privileges.js index 6d425a6f40..6f30165a47 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -9,48 +9,6 @@ * */ -/** - * Validates the password field in a form - * - * @see PMA_messages['strPasswordEmpty'] - * @see PMA_messages['strPasswordNotSame'] - * @param object the form - * @return boolean whether the field value is valid or not - */ -function checkPassword(the_form) -{ - // Did the user select 'no password'? - if (typeof(the_form.elements['nopass']) != 'undefined' - && the_form.elements['nopass'][0].checked) { - return true; - } else if (typeof(the_form.elements['pred_password']) != 'undefined' - && (the_form.elements['pred_password'].value == 'none' - || the_form.elements['pred_password'].value == 'keep')) { - return true; - } - - var password = the_form.elements['pma_pw']; - var password_repeat = the_form.elements['pma_pw2']; - var alert_msg = false; - - if (password.value == '') { - alert_msg = PMA_messages['strPasswordEmpty']; - } else if (password.value != password_repeat.value) { - alert_msg = PMA_messages['strPasswordNotSame']; - } - - if (alert_msg) { - alert(alert_msg); - password.value = ''; - password_repeat.value = ''; - password.focus(); - return false; - } - - return true; -} // end of the 'checkPassword()' function - - /** * Validates the "add a user" form * @@ -167,7 +125,6 @@ $(document).ready(function() { var $form = $(this).find("form[name=usersForm]").last(); if (! checkAddUser($form.get(0))) { - PMA_ajaxShowMessage(PMA_messages['strFormEmpty']); return false; } @@ -263,6 +220,15 @@ $(document).ready(function() { displayPasswordGenerateButton(); PMA_convertFootnotesToTooltips($div); PMA_ajaxRemoveMessage($msgbox); + + $div.find('form[name=usersForm]').bind('submit', function (e) { + e.preventDefault(); + $(this) + .closest('.ui-dialog') + .find('.ui-dialog-buttonpane .ui-button') + .first() + .click(); + }); }); // end $.get() });//end of Add New User AJAX event handler @@ -397,6 +363,10 @@ $(document).ready(function() { /** @lends jQuery */ event.preventDefault(); + if ($(this).is('.copyUserForm') && ! checkPassword($(this)[0])) { + return false; + } + PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']); $(this).append(''); diff --git a/libraries/display_change_password.lib.php b/libraries/display_change_password.lib.php index 3397dd0efb..c5e7865b8a 100644 --- a/libraries/display_change_password.lib.php +++ b/libraries/display_change_password.lib.php @@ -19,7 +19,7 @@ $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5) // Displays the form ?> -
onsubmit="return checkPassword(this)"> + > ' . "\n" diff --git a/server_privileges.php b/server_privileges.php index bb3aaed1a2..6fcb0b9b40 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -2176,7 +2176,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs if (! isset($dbname) && ! $user_does_not_exists) { include_once './libraries/display_change_password.lib.php'; - echo '' . "\n" + echo '' . "\n" . PMA_generate_common_hidden_inputs('', '') . '' . "\n" . '' . "\n"