From f64e42429a901a1c4fff411cb3848b7bbac04c80 Mon Sep 17 00:00:00 2001 From: OddTurtleHead <355182507+OddTurtleHead@users.noreply.github.com> Date: Fri, 4 Dec 2026 13:56:09 +0800 Subject: [PATCH] fix(skins): skip bundled skins in the skin store index instead of rejecting it An index entry whose id is bundled with the client (a protected built-in id or a builtin.-prefixed id) is now dropped from the store catalog instead of failing the whole index with SKIN_STORE_INVALID. Invalid schema, illegal ids, duplicate ids and unsafe repositories still reject the index. This lets the store keep listing every other skin even while the public index still contains a skin that is now bundled. --- src/admin/skin-store.ts | 14 ++++++++++---- web/test/skin-store.test.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/admin/skin-store.ts b/src/admin/skin-store.ts index 4ee5e80..017169b 100644 --- a/src/admin/skin-store.ts +++ b/src/admin/skin-store.ts @@ -27,12 +27,18 @@ function parseIndex(value: unknown): { id: string; repository: string }[] { const root = record(value); if (root.schemaVersion !== 1 || !Array.isArray(root.skins) || root.skins.length > 50) return fail("SKIN_STORE_INVALID"); const seen = new Set(); - return root.skins.map(item => { + const sources: { id: string; repository: string }[] = []; + for (const item of root.skins) { const entry = record(item); - if (typeof entry.id !== "string" || !ID.test(entry.id) || isBuiltinSkinId(entry.id) || entry.id.startsWith("builtin.") || seen.has(entry.id)) return fail("SKIN_STORE_INVALID"); + if (typeof entry.id !== "string" || !ID.test(entry.id) || seen.has(entry.id)) return fail("SKIN_STORE_INVALID"); seen.add(entry.id); - return { id: entry.id, repository: skinRepository(entry.repository) }; - }); + // Skins that ship with the client are not installable from the store. Skip + // such an index entry instead of rejecting the whole index, so an index + // that still lists a newly bundled skin keeps working for every other skin. + if (isBuiltinSkinId(entry.id) || entry.id.startsWith("builtin.")) continue; + sources.push({ id: entry.id, repository: skinRepository(entry.repository) }); + } + return sources; } function parseMetadata(value: unknown, id: string): SkinStoreMetadata { diff --git a/web/test/skin-store.test.ts b/web/test/skin-store.test.ts index eaf228b..04e5f31 100644 --- a/web/test/skin-store.test.ts +++ b/web/test/skin-store.test.ts @@ -102,6 +102,32 @@ test("store rejects unsafe repositories, malformed/duplicate indexes and isolate assert.equal(result.entries[0].metadata, null); assert.equal(result.entries[0].error, "SKIN_STORE_UNAVAILABLE"); }); + +test("store skips index entries for skins bundled with the client and keeps the other skins", async () => { + const f = fixture(); + f.index.skins.unshift({ id: "community.ts3-classic-console", repository }); + f.index.skins.push({ id: "community.kaak-voice", repository }, { id: "builtin.future-pack", repository: "not a repository" }); + const result = await new SkinStore("0.3.4-dev.0", f.fetcher).list(); + assert.deepEqual(result.entries.map(entry => entry.id), [manifest.id], "bundled and builtin.-prefixed entries are dropped, other skins stay"); + assert.equal(result.entries[0].error, null); + assert.ok(!f.calls.some(url => url.includes("classic") || url.includes("kaak") || url.includes("future-pack")), "skipped entries are never downloaded"); +}); +test("store still rejects malformed, duplicate or unsafe index entries after skipping bundled skins", async () => { + const cases: unknown[] = [ + { schemaVersion: 2, skins: [{ id: manifest.id, repository }] }, + { schemaVersion: 1, skins: "community.store-test" }, + { schemaVersion: 1, skins: [{ id: "Bad Id", repository }] }, + { schemaVersion: 1, skins: [{ id: manifest.id, repository }, { id: manifest.id, repository }] }, + { schemaVersion: 1, skins: [{ id: "community.ts3-classic-console", repository }, { id: "community.ts3-classic-console", repository }] }, + { schemaVersion: 1, skins: [{ id: "community.ts3-classic-console", repository }, { id: manifest.id, repository: "https://example.com/skin" }] }, + { schemaVersion: 1, skins: [null] }, + ]; + for (const index of cases) { + const f = fixture(); + f.overrides.set(SKIN_STORE_INDEX_URL, () => Response.json(index)); + await assert.rejects(new SkinStore("0.3.4-dev.0", f.fetcher).list(), errorCode("SKIN_STORE_INVALID"), JSON.stringify(index)); + } +}); test("store bounds downloads and validates checksum, package identity and metadata before saving", async t => { const f = fixture(), store = new SkinStore("0.2.8", f.fetcher), skins = await registry(t); const entry = (await store.list()).entries[0], input = { id: entry.id, revision: entry.revision, installedVersion: null };