From c503edaae093b8e44574ca231af2f02ee2c8f6f0 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Fri, 20 Nov 2026 13:38:49 +0700 Subject: [PATCH 1/2] fix(pwa): require genuine OnAir manifest before reconnecting --- public/offline.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/offline.html b/public/offline.html index 78fee9ea..2e2dd09d 100644 --- a/public/offline.html +++ b/public/offline.html @@ -113,8 +113,9 @@

You're offline

}); if (!response.ok) throw new Error('Connection unavailable'); const manifest = await response.json(); - if (typeof manifest?.name !== 'string' || typeof manifest?.start_url !== 'string') { - throw new Error('Invalid response'); + if (manifest?.name !== 'ePlus OnAir — Listen Beyond Borders.' + || manifest?.start_url !== '../' || manifest?.scope !== '../') { + throw new Error('Unexpected website manifest'); } restored = true; From 0738c7287bf0592b924456137c9d9bc756502213 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Fri, 20 Nov 2026 13:38:52 +0700 Subject: [PATCH 2/2] test(pwa): avoid CodeQL-flagged HTML regex and exercise strict manifest validation --- tests/pwa-reconnect.test.mjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/pwa-reconnect.test.mjs b/tests/pwa-reconnect.test.mjs index ef25d466..a1a61085 100644 --- a/tests/pwa-reconnect.test.mjs +++ b/tests/pwa-reconnect.test.mjs @@ -7,8 +7,11 @@ const read = path => readFile(new URL('../' + path, import.meta.url), 'utf8'); async function offlinePageHarness({ reachable = false, hidden = false, validManifest = true, serviceWorkerFails = false } = {}) { const html = await read('public/offline.html'); - const script = html.match(/', start); + assert.ok(start >= 0 && end > start, 'offline page must contain a self-contained reconnect script'); + const script = html.slice(start + openingTag.length, end); const state = { reachable, validManifest }; const windowEvents = new Map(); @@ -58,7 +61,7 @@ async function offlinePageHarness({ reachable = false, hidden = false, validMani return { ok: true, json: async () => state.validManifest - ? { name: 'ePlus OnAir', start_url: '../' } + ? { name: 'ePlus OnAir — Listen Beyond Borders.', start_url: '../', scope: '../' } : { unexpected: 'captive portal' }, }; },