luci-app-samba4: prevent calling split() on array or null values

Since `uci.get()` may return null or array values, we cannot blindly call
split() on the result. Use the safe `L.toArray()` helper which is intended
to deal with such situations.

Also clean up whitespace while we're at.

Fixes: #5080
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2021-05-31 11:25:54 +02:00
parent 00d518d697
commit c4cdfcbe51

View file

@ -35,7 +35,7 @@ return view.extend({
_('Listen only on the given interface or, if unspecified, on lan'));
o.multiple = true;
o.cfgvalue = function(section_id) {
return uci.get('samba4', section_id, 'interface').split(' ');
return L.toArray(uci.get('samba4', section_id, 'interface'));
};
o.write = function(section_id, formvalue) {
var cfgvalue = this.cfgvalue(section_id),