Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix(extension): match feed appid by comparison, not a regex built from --id (#1274)

kyle-elliott-asymptotea67e54f9e0c1
diff --git a/browser-extension/test/unit/pack-crx.test.ts b/browser-extension/test/unit/pack-crx.test.ts
index c6df3f06..18f3e2ac 100644
--- a/browser-extension/test/unit/pack-crx.test.ts
+++ b/browser-extension/test/unit/pack-crx.test.ts
@@ -87,6 +87,7 @@ describe('update feed', () => {
);
expect(feedVersion(xml, id)).toBe('0.2.0');
expect(feedVersion(xml, 'pppppppppppppppppppppppppppppppp')).toBeUndefined();
+ expect(feedVersion(xml, '.'.repeat(32))).toBeUndefined();
});
it('refuses values Chrome would reject', () => {
diff --git a/browser-extension/tools/pack-crx.mjs b/browser-extension/tools/pack-crx.mjs
index a23133b2..46531a2b 100644
--- a/browser-extension/tools/pack-crx.mjs
+++ b/browser-extension/tools/pack-crx.mjs
@@ -138,10 +138,16 @@ export function feedXml({ id, version, codebase, sha256: hash }) {
].join('\n');
}
-/** The version a feed offers for `id`, or undefined when it names none. Reads only what feedXml writes. */
+/**
+ * The version a feed offers for `id`, or undefined when it names none. Reads only what feedXml writes.
+ * `id` is compared to each app's appid rather than built into the pattern, so no value of it can
+ * change what the pattern matches.
+ */
export function feedVersion(xml, id) {
- const app = new RegExp(`<app\\s+appid=['"]${id}['"][^>]*>([\\s\\S]*?)</app>`).exec(xml);
- return app ? /\bversion=['"]([^'"]+)['"]/.exec(app[1])?.[1] : undefined;
+ for (const [, appid, body] of xml.matchAll(/<app\s+appid=['"]([^'"]*)['"][^>]*>([\s\S]*?)<\/app>/g)) {
+ if (appid === id) return /\bversion=['"]([^'"]+)['"]/.exec(body)?.[1];
+ }
+ return undefined;
}
/** The signed build's asset name on an `ext-v<version>` release. */