luci-mod-network: fix logic bug in parse enc for network join 4561/head
authorAnsuel Smith <ansuelsmth@gmail.com>
Sun, 1 Nov 2020 00:51:02 +0000 (01:51 +0100)
committerAnsuel Smith <ansuelsmth@gmail.com>
Sun, 1 Nov 2020 00:51:02 +0000 (01:51 +0100)
In handleJoinConfirm while is_wep is a boolean, is_psk and is_sae are an array. In the following if check, all 3 are used as boolean but Js treat empty array as positive values and this cause the ui to wrongly set the encryption to sae. fix this by checking if the array actually contains data.

Fixes: #4524
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js

index 26ddbaa19bab3f51a1f17dea0db6f98e3f4b240a..d53f973588898218c735f6e1f4fc7a9fc68a6e22 100644 (file)
@@ -1841,11 +1841,11 @@ return view.extend({
                                        uci.set('wireless', section_id, 'bssid', bss.bssid);
                                }
 
-                               if (is_sae) {
+                               if (is_sae.length > 0) {
                                        uci.set('wireless', section_id, 'encryption', 'sae');
                                        uci.set('wireless', section_id, 'key', passval);
                                }
-                               else if (is_psk) {
+                               else if (is_psk.length > 0) {
                                        for (var i = enc.wpa.length - 1; i >= 0; i--) {
                                                if (enc.wpa[i] == 2) {
                                                        uci.set('wireless', section_id, 'encryption', 'psk2');