mirror of
https://github.com/openwrt/luci
synced 2025-01-08 12:08:04 +08:00
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 <dannil+github@protonmail.com>
This commit is contained in:
parent
7c582f150e
commit
c9cc773449
@ -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<br/>'); // Inserts <br> after every 2 characters (hex pair)
|
||||
|
Loading…
Reference in New Issue
Block a user