Escape what the arrs report about themselves, and give the tab an assistant

Health messages go straight from each arr's API into innerHTML and quote things
nobody here controls — indexer names from Prowlarr, import-list names, release
titles. The page used no escaping at all. _sz() was also binary while labelling
its output TB, so /tv read 86.9 TB here and 95.6 TB on every other tab; it has
one caller and that caller is disk capacity, so it now matches the rest.
This commit is contained in:
Gmer4Lfe
2026-08-14 17:51:04 -04:00
parent 793a75b8a2
commit a11e3d73a7
2 changed files with 62 additions and 12 deletions
+13 -4
View File
@@ -23,12 +23,21 @@ function _fmtBytes(b) {
return (b / 1024).toFixed(0) + ' KB';
}
// Bytes → auto-scale TB / GB / MB
// Bytes → auto-scale TB / GB / MB, decimal.
//
// Its only caller is the arr disk bar, which is showing the same storage the Monitor and Watchdog
// tabs show. Those were moved to decimal so a disk reads the same number here as on Unraid's own
// Main page and as printed on the drive; leaving this one binary made /tv 86.9 TB on this tab and
// 95.6 TB on the next, which is worse than either convention chosen consistently.
//
// Capacity is decimal, memory stays binary — 128 GB of RAM genuinely is 125.8 GiB and every tool
// on the box agrees. See _vv_api_bytes_to_gib() in include/unraid_api.php for the same split on
// the PHP side.
function _sz(b) {
if (!b) return '—';
if (b >= _TB) return (b / _TB).toFixed(1) + ' TB';
if (b >= _GB) return (b / _GB).toFixed(1) + ' GB';
return (b / _MB).toFixed(0) + ' MB';
if (b >= 1e12) return (b / 1e12).toFixed(1) + ' TB';
if (b >= 1e9) return (b / 1e9).toFixed(1) + ' GB';
return (b / 1e6).toFixed(0) + ' MB';
}
function _gb(b) { return !b ? '—' : (b / _GB).toFixed(1) + ' GB'; }