From a59f0c970e11807947d98b8426bd17ceabd41247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obernd=C3=B6rfer?= Date: Tue, 29 Jan 2013 14:28:59 +0100 Subject: [PATCH] Preferences input validation --- common/ui/keyRing.html | 3 ++- common/ui/preferences.js | 23 ++++++++++++++++++++--- dist/mailvelope.zip | Bin 1447468 -> 1447648 bytes 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/common/ui/keyRing.html b/common/ui/keyRing.html index 1addb21cc..ae0765a6c 100644 --- a/common/ui/keyRing.html +++ b/common/ui/keyRing.html @@ -306,7 +306,8 @@

Preferences

- + + Must be 3 characters
diff --git a/common/ui/preferences.js b/common/ui/preferences.js index e513c213e..545044432 100644 --- a/common/ui/preferences.js +++ b/common/ui/preferences.js @@ -29,20 +29,37 @@ } function onSave() { + if (!validate()) return false; prefs.security.display_decrypted = $('input:radio[name="decryptRadios"]:checked').val(); prefs.security.secure_code = $('#secCode').val(); prefs.security.secure_color = $('#secColor').val(); keyRing.sendMessage({ event: 'set-prefs', data: prefs }, function() { keyRing.update(); - $('.form-actions button').attr('disabled', 'disabled'); + normalize(); }); - + return false; + } + + function validate() { + var secCode = $('#secCode'); + if (secCode.val().length !== 3) { + secCode.closest('.control-group').addClass('error'); + secCode.next().removeClass('hide'); + return false; + } + return true; + } + function normalize() { + $('#preferences .form-actions button').attr('disabled', 'disabled'); + $('#preferences .control-group').removeClass('error'); + $('#preferences .help-inline').addClass('hide'); } function onCancel() { - $('.form-actions button').attr('disabled', 'disabled'); + normalize(); loadPrefs(); + return false; } function loadPrefs() { diff --git a/dist/mailvelope.zip b/dist/mailvelope.zip index 69285221fbb0db21e8c2cc0c6a3be7703051b16e..0337ce5f9da9b3578c36af30842f5e3b36e94c01 100644 GIT binary patch delta 5102 zcmY*dcQl-B(_f3lT9&nLy+)UiY=|B$dXL_sM6V%43#)A+O0*=mmWUAKAq3HTCq!>i zHxZo;LX;?7-bM853rnuM)|K2P-nkX6?O&m=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