From ae30bc85100dab58d84fabcb57b70ba78e88a530 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Sat, 21 Nov 2026 18:06:27 +0700 Subject: [PATCH 1/2] fix(playback): avoid re-proxying canonical-equivalent proxy URLs --- utils/radio-source-plan.mjs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/radio-source-plan.mjs b/utils/radio-source-plan.mjs index da9c12dc..69493611 100644 --- a/utils/radio-source-plan.mjs +++ b/utils/radio-source-plan.mjs @@ -41,12 +41,15 @@ export const buildPlaybackSources = (sources, corsServer) => { // Never forward URL-embedded credentials to a third-party CORS proxy. // Preserve the direct candidate; only suppress its proxy fallback. let hasCredentials = false; + let alreadyProxied = false; try { const parsed = new URL(src); // Signed stream URLs (including AWS/GCS provider-specific query fields) must not reach third-party proxies. const sensitiveQuery = [...parsed.searchParams.keys()].some(key => /^(?:x-amz-.+|x-goog-.+|awsaccesskeyid|googleaccessid|token|(?:access|refresh|id|auth|session)[_-]?token|access[_-]?key|api[_-]?key|client[_-]?secret|session[_-]?key|auth(?:orization)?|signature|sig|secret|password|jwt|expires?|policy|key[_-]?pair[_-]?id)$/i.test(key)); hasCredentials = Boolean(parsed.username || parsed.password || sensitiveQuery); + // URL canonicalization normalizes host casing and default ports, unlike a raw string prefix check. + alreadyProxied = Boolean(proxyBase) && parsed.href.startsWith(new URL(proxyBase).href); } catch { /* Invalid URLs are not eligible for proxy fallback. */ hasCredentials = true; } @@ -57,7 +60,7 @@ export const buildPlaybackSources = (sources, corsServer) => { !isHls && !source.proxied && /^https?:\/\//i.test(src) && - !src.startsWith(proxyBase); + !alreadyProxied; if (canProxy) { push({ From 82e7faff8c019a9eef14dfe8c5b9250e20b29fc7 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Sat, 21 Nov 2026 18:06:31 +0700 Subject: [PATCH 2/2] test(playback): cover proxy URL canonicalization regression --- tests/radio-source-plan.test.mjs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/radio-source-plan.test.mjs b/tests/radio-source-plan.test.mjs index f599b03e..16b96798 100644 --- a/tests/radio-source-plan.test.mjs +++ b/tests/radio-source-plan.test.mjs @@ -203,3 +203,16 @@ test("never forwards OAuth-style stream credentials to a third-party proxy", () ]); assert.equal(result.filter(item => item.proxied).length, 1); }); + + +test("does not re-proxy an already proxied URL with canonical-equivalent host casing or port", () => { + const alreadyProxied = "https://CORS.EXAMPLE:443/https://radio.example/live.mp3"; + const result = buildPlaybackSources([{ src: alreadyProxied }], "https://cors.example/"); + assert.deepEqual(result.map(item => item.src), [alreadyProxied]); + + const otherStream = "https://radio.example/live.mp3"; + assert.deepEqual( + buildPlaybackSources([{ src: otherStream }], "https://cors.example/").map(item => item.src), + [otherStream, "https://cors.example/https://radio.example/live.mp3"], + ); +});