From: Daniel Nilsson Date: Mon, 6 Jan 2025 16:37:45 +0000 (+0100) Subject: luci-mod-network: handle missing dnsrr hexdata as empty string X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c9cc773449d71d930ed2fd1e4e8a1dd95d91ae25;p=project%2Fluci.git luci-mod-network: handle missing dnsrr hexdata as empty string If the value returned from UCI was falsy, it became an empty array instead of an empty string, which crashed the UI when trying to invoke the non-existing replace instance function on the value. Signed-off-by: Daniel Nilsson --- diff --git a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js index 28d824a08e..afe21259cc 100644 --- a/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js +++ b/modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js @@ -1067,13 +1067,13 @@ return view.extend({ ss.nodescriptions = true; function hexdecodeload(section_id) { - let arr = uci.get('dhcp', section_id, this.option) || []; + let value = uci.get('dhcp', section_id, this.option) || ''; // Remove any spaces or colons from the hex string - they're allowed - arr = arr.replace(/[\s:]/g, ''); + value = value.replace(/[\s:]/g, ''); // Hex-decode the string before displaying let decodedString = ''; - for (let i = 0; i < arr.length; i += 2) { - decodedString += String.fromCharCode(parseInt(arr.substr(i, 2), 16)); + for (let i = 0; i < value.length; i += 2) { + decodedString += String.fromCharCode(parseInt(value.substr(i, 2), 16)); } return decodedString; } @@ -1109,7 +1109,7 @@ return view.extend({ so.width = '10%'; so.rawhtml = true; so.load = function(section_id) { - let hexdata = uci.get('dhcp', section_id, 'hexdata') || []; + let hexdata = uci.get('dhcp', section_id, 'hexdata') || ''; hexdata = hexdata.replace(/[:]/g, ''); if (hexdata) { return hexdata.replace(/(.{20})/g, '$1
'); // Inserts
after every 2 characters (hex pair)