From a0abfb3a62aa6aa56057ece2992d797d3287692d Mon Sep 17 00:00:00 2001 From: Rene Fichtmueller Date: Mon, 30 Mar 2026 05:55:43 +0200 Subject: [PATCH] fix: WHOIS defensive HTML response check, prevent Unexpected token error --- public/index-editorial.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/index-editorial.html b/public/index-editorial.html index aeba8ca..1d40521 100644 --- a/public/index-editorial.html +++ b/public/index-editorial.html @@ -2570,11 +2570,14 @@ async function loadWhoisData(asn) { $('whoisContent').innerHTML = '
Loading WHOIS data...
'; try { var resp = await fetch('/api/whois?resource=AS' + asn); - var d = await resp.json(); + if (!resp.ok) { $('whoisContent').innerHTML = '
WHOIS unavailable (server ' + resp.status + ')
'; return; } + var text = await resp.text(); + if (!text || text[0] === '<') { $('whoisContent').innerHTML = '
WHOIS temporarily unavailable
'; return; } + var d = JSON.parse(text); if (d.error) { $('whoisContent').innerHTML = '
WHOIS: ' + escHtml(d.error) + '
'; return; } renderWhois(d); } catch (e) { - $('whoisContent').innerHTML = '
WHOIS lookup failed: ' + escHtml(e.message) + '
'; + $('whoisContent').innerHTML = '
WHOIS lookup failed: ' + escHtml(e.message) + '
'; } }