fix(desktop): keep non-ASCII desktop entries out of Open In matching (#3403)
desktopEntryMatchesApp normalized haystack values without dropping empty
ones, so a .desktop entry with no ASCII letters or digits in Name, id,
file name, or Exec (e.g. Name=抖音) normalized to "" and
needle.includes("") matched every requested app — hijacking the
installed-apps list and Open In launch specs. Empty normalized haystack
values are now filtered, matching the existing needles handling.
discovered-apps.json gains a version field (INSTALLED_APPS_CACHE_VERSION
= 2); caches written before the fix are treated as stale and refresh
through the existing TTL-expiry path instead of serving the poisoned
list for the rest of the 24h TTL.
This commit is contained in:
@@ -246,6 +246,9 @@ const GITHUB_FEATURE_REQUEST_URL = 'https://github.com/openchamber/openchamber/i
|
||||
const DISCORD_INVITE_URL = 'https://discord.gg/ZYRSdnwwKA';
|
||||
const INSTALLED_APPS_CACHE_TTL_SECS = 60 * 60 * 24;
|
||||
const INSTALLED_APPS_CACHE_FILE = 'discovered-apps.json';
|
||||
// Bump when discovery results change shape or matching semantics change, so cached
|
||||
// entries written by an older build are treated as stale and refresh immediately.
|
||||
const INSTALLED_APPS_CACHE_VERSION = 2;
|
||||
const LINUX_DESKTOP_ENTRIES_CACHE_TTL_MS = 30_000;
|
||||
const OPENCODE_SHUTDOWN_GRACE_MS = 100;
|
||||
const { autoUpdater } = updaterPkg;
|
||||
@@ -4428,11 +4431,13 @@ const handleInvoke = async (browserWindow, command, args = {}) => {
|
||||
}
|
||||
const cachedApps = Array.isArray(cache?.apps) ? cache.apps : [];
|
||||
const hasCache = Boolean(cache);
|
||||
const isCacheStale = !cache || (now - Number(cache.updatedAt || 0)) > INSTALLED_APPS_CACHE_TTL_SECS;
|
||||
const isCacheStale = !cache
|
||||
|| cache.version !== INSTALLED_APPS_CACHE_VERSION
|
||||
|| (now - Number(cache.updatedAt || 0)) > INSTALLED_APPS_CACHE_TTL_SECS;
|
||||
const refresh = async () => {
|
||||
const apps = await buildPlatformInstalledApps(Array.isArray(args.apps) ? args.apps : []);
|
||||
await fsp.mkdir(path.dirname(cachePath), { recursive: true });
|
||||
await fsp.writeFile(cachePath, JSON.stringify({ updatedAt: now, apps }, null, 2));
|
||||
await fsp.writeFile(cachePath, JSON.stringify({ version: INSTALLED_APPS_CACHE_VERSION, updatedAt: now, apps }, null, 2));
|
||||
emitToAllWindows('openchamber:installed-apps-updated', apps);
|
||||
};
|
||||
if (process.platform !== 'darwin' && process.platform !== 'win32' && process.platform !== 'linux') {
|
||||
|
||||
Reference in New Issue
Block a user