






















@@ -26,6 +26,22 @@ type BundledCandidateResolution = {
2626manifestRecords?: readonly PluginManifestRecord[];
2727};
282829+function filterRespectAllowBundledPluginIds(
30+config: PluginLoadOptions["config"] | undefined,
31+pluginIds: readonly string[],
32+) {
33+const allow = config?.plugins?.allow;
34+if (
35+config?.plugins?.bundledMode !== "respect-allow" ||
36+!Array.isArray(allow) ||
37+allow.length === 0
38+) {
39+return [...pluginIds];
40+}
41+const allowedPluginIds = new Set(allow.map((pluginId) => pluginId.trim()).filter(Boolean));
42+return pluginIds.filter((pluginId) => allowedPluginIds.has(pluginId));
43+}
44+2945function resolveBundledCandidatePluginIds(params: {
3046contract: "webSearchProviders" | "webFetchProviders";
3147configKey: "webSearch" | "webFetch";
@@ -35,17 +51,17 @@ function resolveBundledCandidatePluginIds(params: {
3551bundledAllowlistCompat?: boolean;
3652onlyPluginIds?: readonly string[];
3753}): BundledCandidateResolution {
38-if (params.onlyPluginIds && params.onlyPluginIds.length > 0) {
39-return {
40-pluginIds: [...new Set(params.onlyPluginIds)].toSorted((left, right) =>
41-left.localeCompare(right),
42-),
43-};
44-}
4554const resolvedConfig =
4655params.contract === "webSearchProviders"
4756 ? resolveBundledWebSearchResolutionConfig(params).config
4857 : resolveBundledWebFetchResolutionConfig(params).config;
58+if (params.onlyPluginIds && params.onlyPluginIds.length > 0) {
59+return {
60+pluginIds: filterRespectAllowBundledPluginIds(resolvedConfig, [
61+ ...new Set(params.onlyPluginIds),
62+]).toSorted((left, right) => left.localeCompare(right)),
63+};
64+}
4965const candidates = resolveManifestDeclaredWebProviderCandidates({
5066contract: params.contract,
5167configKey: params.configKey,
@@ -56,7 +72,7 @@ function resolveBundledCandidatePluginIds(params: {
5672origin: "bundled",
5773});
5874return {
59-pluginIds: candidates.pluginIds ?? [],
75+pluginIds: filterRespectAllowBundledPluginIds(resolvedConfig, candidates.pluginIds ?? []),
6076 ...(candidates.manifestRecords ? { manifestRecords: candidates.manifestRecords } : {}),
6177};
6278}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。