From 662ce3b0008fbe938eb9f3d346fe51fce461b3ca Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 17 Nov 2026 14:13:04 +0700 Subject: [PATCH 1/2] fix(schedule): reject malformed and credential-bearing EPG URLs --- utils/station-schedule.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/station-schedule.mjs b/utils/station-schedule.mjs index afb163a21..e76e9252e 100644 --- a/utils/station-schedule.mjs +++ b/utils/station-schedule.mjs @@ -4,7 +4,14 @@ export const normalizeScheduleUrl = (value) => { const url = value.trim(); if (!/^https?:\/\//i.test(url)) return ""; - return url; + try { + const parsed = new URL(url); + // Reject malformed endpoints and embedded credentials before a schedule fetch. + if (!["http:", "https:"].includes(parsed.protocol) || !parsed.hostname || parsed.username || parsed.password) return ""; + return url; + } catch { + return ""; + } }; export const isZingScheduleUrl = (value) => { From 5bebaa5af217b622257e9a0516838d3a9a29f929 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Tue, 17 Nov 2026 14:13:06 +0700 Subject: [PATCH 2/2] test(schedule): cover malformed and credential-bearing URLs --- tests/station-schedule.test.mjs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/station-schedule.test.mjs b/tests/station-schedule.test.mjs index b770b2633..826430e6a 100644 --- a/tests/station-schedule.test.mjs +++ b/tests/station-schedule.test.mjs @@ -20,6 +20,10 @@ test("normalizes only real HTTP schedule URLs", () => { assert.equal(normalizeScheduleUrl(false), ""); assert.equal(normalizeScheduleUrl(""), ""); assert.equal(normalizeScheduleUrl("schedule-only"), ""); + assert.equal(normalizeScheduleUrl("https://"), ""); + assert.equal(normalizeScheduleUrl("https://example.com:bad/epg"), ""); + assert.equal(normalizeScheduleUrl("https://user:pass@example.com/epg"), ""); + assert.equal(normalizeScheduleUrl("https://example.com/epg"), "https://example.com/epg"); }); test("detects Zing schedule by provider endpoint instead of country", () => {