diff --git a/components/plugins/PluginContributionIcon.tsx b/components/plugins/PluginContributionIcon.tsx
index fad2cf44f..a855d5e6a 100644
--- a/components/plugins/PluginContributionIcon.tsx
+++ b/components/plugins/PluginContributionIcon.tsx
@@ -60,7 +60,7 @@ export function PluginContributionIcon({
const packageIcon = usePluginContributionIcon(pluginId, icon);
if (icon?.kind === 'theme') {
- const Icon = THEME_ICONS[icon.name] ?? Puzzle;
+ const Icon = Object.hasOwn(THEME_ICONS, icon.name) ? THEME_ICONS[icon.name] : Puzzle;
return ;
}
if (packageIcon) {
diff --git a/components/settings/tabs/PluginBrandIcon.test.tsx b/components/settings/tabs/PluginBrandIcon.test.tsx
index d59f531e9..2a0fc173a 100644
--- a/components/settings/tabs/PluginBrandIcon.test.tsx
+++ b/components/settings/tabs/PluginBrandIcon.test.tsx
@@ -58,3 +58,13 @@ test('installed brand uses metadata only, rejects stale responses, and falls bac
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = previousAct;
}
});
+
+
+test('disabled brand theme names cannot resolve Object prototype members', () => {
+ for (const name of ['constructor', '__proto__', 'toString', 'valueOf', 'hasOwnProperty']) {
+ const plugin = { id: 'com.test.theme', enabled: false, activeVersion: '1.0.0', runtime: {}, manifest: { icon: { kind: 'theme', name } } } as NetcattyInstalledPlugin;
+ const html = renderToStaticMarkup();
+ assert.match(html, /lucide-puzzle/);
+ assert.doesNotMatch(html, /
{
+function openZip(filePath: string, autoClose = true): Promise {
return new Promise((resolve, reject) => {
yauzl.open(
filePath,
@@ -512,7 +512,7 @@ function openZip(filePath: string): Promise {
// AssertByteCountStream that rejects an overflowing chunk before it is
// forwarded to readEntry(). Combined with the metadata limits below,
// captured manifest contents cannot exceed PACKAGE_LIMITS.manifestBytes.
- { lazyEntries: true, decodeStrings: true, strictFileNames: true, validateEntrySizes: true },
+ { lazyEntries: true, autoClose, decodeStrings: true, strictFileNames: true, validateEntrySizes: true },
(error, zipFile) => {
if (error || !zipFile) reject(error ?? new Error("Unable to open plugin archive"));
else resolve(zipFile);
@@ -659,9 +659,11 @@ async function inspectPluginPackage(
if (archiveStats.size > PACKAGE_LIMITS.archiveBytes) {
throw new Error(`Plugin archive exceeds ${PACKAGE_LIMITS.archiveBytes} bytes`);
}
- const zipFile = await openZip(archivePath);
+ const zipFile = await openZip(archivePath, false);
+ try {
const registry = new PackagePathRegistry();
const entries = new Map PLUGIN_BRAND_ICON_MAX_BYTES) throw new Error('Brand icon is missing or exceeds size limit');
+ const result = await readEntry(zipFile, record.zipEntry, true);
+ if (!result.contents || result.sha256 !== record.sha256 || result.bytes !== record.size
+ || result.crc32 !== record.zipEntry.crc32) throw new Error('Brand icon changed during archive validation');
+ inspectPluginBrandIcon(result.contents, iconPath);
}
for (const [companionPath, companion] of declaredCompanions) {
const entry = entries.get(companionPath);
@@ -789,6 +798,7 @@ async function inspectPluginPackage(
})),
);
return { manifest, fileCount: entries.size, uncompressedBytes: totalBytes, contentSha256 };
+ } finally { zipFile.close(); }
}
export async function validatePluginPackage(
diff --git a/packages/plugin-cli/src/brandIcons.test.ts b/packages/plugin-cli/src/brandIcons.test.ts
index 97145cef4..d7dc49890 100644
--- a/packages/plugin-cli/src/brandIcons.test.ts
+++ b/packages/plugin-cli/src/brandIcons.test.ts
@@ -55,3 +55,25 @@ test('directory validation, packing and archive validation include both brand re
await writeFile(path.join(dir, 'assets/logo-dark.png'), Buffer.alloc(256 * 1024 + 1));
await assert.rejects(validatePluginDirectory(dir), /size limit/);
});
+
+test('undeclared PNG assets remain streamed even when their names sort before the manifest', async (t) => {
+ const root = await mkdtemp(path.join(tmpdir(), 'netcatty-brand-stream-'));
+ t.after(() => rm(root, { recursive: true, force: true }));
+ const dir = path.join(root, 'plugin'); await mkdir(dir);
+ const { icon: _icon, features: _features, ...plain } = manifest;
+ await writeFile(path.join(dir, 'netcatty.plugin.json'), JSON.stringify({ ...plain, main: { browser: 'index.js' }, contributes: undefined, activationEvents: [] }));
+ await writeFile(path.join(dir, 'index.js'), 'export function activate() {}');
+ for (let i = 0; i < 16; i++) await writeFile(path.join(dir, `a-${i}.png`), Buffer.alloc(240 * 1024));
+ const archive = path.join(root, 'no-brand.ncpkg'); await buildPluginPackage(dir, archive);
+ // Instrument the explicit byte aggregation boundary, not RSS/GC timing.
+ const originalConcat = Buffer.concat; let retainedImageBodies = 0;
+ Buffer.concat = (list, totalLength) => {
+ if (list.reduce((sum, item) => sum + item.length, 0) >= 240 * 1024) retainedImageBodies++;
+ return originalConcat(list, totalLength);
+ };
+ try {
+ const result = await validatePluginPackage(archive);
+ assert.equal(result.fileCount, 18);
+ assert.equal(retainedImageBodies, 0, 'unreferenced images must never be concatenated and retained');
+ } finally { Buffer.concat = originalConcat; }
+});