Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #9833 from masap/20130517
Browse files Browse the repository at this point in the history
Bug 802137 - [WiFi] WEP key length should be 5 or 13 (r=fcampo,arthurcc)
  • Loading branch information
Fernando Campo committed May 28, 2013
2 parents 6dbaa14 + 7028fc2 commit 5d5013b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 24 deletions.
15 changes: 3 additions & 12 deletions apps/communications/ftu/js/wifi.js
Expand Up @@ -204,18 +204,9 @@ var WifiUI = {
joinButton.disabled = true;
passwordInput.addEventListener('keyup', function validatePassword() {
// disable the "Join" button if the password is too short
var disabled = false;
switch (WifiHelper.getKeyManagement(selectedNetwork)) {
case 'WPA-PSK':
disabled = disabled || passwordInput.value.length < 8;
break;
case 'WPA-EAP':
disabled = disabled || userInput.value.length < 1;
case 'WEP':
disabled = disabled || passwordInput.value.length < 1;
break;
}
joinButton.disabled = disabled;
joinButton.disabled =
!WifiHelper.isValidInput(WifiHelper.getKeyManagement(selectedNetwork),
passwordInput.value, userInput.value);
});

// Show / Hide password
Expand Down
14 changes: 2 additions & 12 deletions apps/settings/js/wifi.js
Expand Up @@ -601,18 +601,8 @@ navigator.mozL10n.ready(function wifiSettings() {
// disable the "OK" button if the password is too short
if (password) {
var checkPassword = function checkPassword() {
var disabled = false;
switch (key) {
case 'WPA-PSK':
disabled = disabled || (password && password.value.length < 8);
break;
case 'WPA-EAP':
disabled = disabled || (identity && identity.value.length < 1);
case 'WEP':
disabled = disabled || (password && password.value.length < 1);
break;
}
dialog.querySelector('button[type=submit]').disabled = disabled;
dialog.querySelector('button[type=submit]').disabled =
!WifiHelper.isValidInput(key, password.value, identity.value);
};
password.oninput = checkPassword;
identity.oninput = checkPassword;
Expand Down
36 changes: 36 additions & 0 deletions shared/js/wifi_helper.js
Expand Up @@ -159,6 +159,42 @@ var WifiHelper = {
return '';
},

isValidInput: function(key, password, identity) {
function isValidWepKey(password) {
switch (password.length) {
case 5:
case 13:
case 16:
case 29:
return true;
case 10:
case 26:
case 32:
case 58:
return !/[^a-fA-F0-9]/.test(password);
default:
return false;
}
}

switch (key) {
case 'WPA-PSK':
if (!password || password.length < 8)
return false;
break;
case 'WPA-EAP':
if (!password || password.length < 1 ||
!identity || identity.length < 1)
return false;
break;
case 'WEP':
if (!password || !isValidWepKey(password))
return false;
break;
}
return true;
},

isOpen: function(network) {
return this.getKeyManagement(network) === '';
},
Expand Down

0 comments on commit 5d5013b

Please sign in to comment.