Pier Angelo Vendrame pushed to branch tor-browser-140.3.0esr-15.0-1 at The Tor Project / Applications / Tor Browser
Commits:
-
a285b441
by Pier Angelo Vendrame at 2025-09-23T19:45:32+02:00
-
771d640c
by Pier Angelo Vendrame at 2025-09-23T19:46:39+02:00
5 changed files:
- browser/components/search/SearchUIUtils.sys.mjs
- toolkit/components/search/OpenSearchLoader.sys.mjs
- toolkit/components/search/SearchService.sys.mjs
- toolkit/components/search/nsISearchService.idl
- toolkit/components/tor-launcher/TorDomainIsolator.sys.mjs
Changes:
... | ... | @@ -181,7 +181,11 @@ export var SearchUIUtils = { |
181 | 181 | */
|
182 | 182 | async addOpenSearchEngine(locationURL, image, browsingContext) {
|
183 | 183 | try {
|
184 | - await Services.search.addOpenSearchEngine(locationURL, image);
|
|
184 | + await Services.search.addOpenSearchEngine(
|
|
185 | + locationURL,
|
|
186 | + image,
|
|
187 | + browsingContext?.originAttributes
|
|
188 | + );
|
|
185 | 189 | } catch (ex) {
|
186 | 190 | let titleMsgName;
|
187 | 191 | let descMsgName;
|
... | ... | @@ -97,10 +97,17 @@ const MOZSEARCH_LOCALNAME = "SearchPlugin"; |
97 | 97 | * The uri from which to load the OpenSearch engine data.
|
98 | 98 | * @param {string} [lastModified]
|
99 | 99 | * The UTC date when the engine was last updated, if any.
|
100 | + * @param {object} [originAttributes]
|
|
101 | + * The first party domain of the site loading that manifest. The domain of the
|
|
102 | + * manifest will be used if not provided.
|
|
100 | 103 | * @returns {Promise<OpenSearchProperties>}
|
101 | 104 | * The properties of the loaded OpenSearch engine.
|
102 | 105 | */
|
103 | -export async function loadAndParseOpenSearchEngine(sourceURI, lastModified) {
|
|
106 | +export async function loadAndParseOpenSearchEngine(
|
|
107 | + sourceURI,
|
|
108 | + lastModified,
|
|
109 | + originAttributes
|
|
110 | +) {
|
|
104 | 111 | if (!sourceURI) {
|
105 | 112 | throw Components.Exception(
|
106 | 113 | "Must have URI when calling _install!",
|
... | ... | @@ -116,7 +123,7 @@ export async function loadAndParseOpenSearchEngine(sourceURI, lastModified) { |
116 | 123 | |
117 | 124 | lazy.logConsole.debug("Downloading OpenSearch engine from:", sourceURI.spec);
|
118 | 125 | |
119 | - let xmlData = await loadEngineXML(sourceURI, lastModified);
|
|
126 | + let xmlData = await loadEngineXML(sourceURI, lastModified, originAttributes);
|
|
120 | 127 | let xmlDocument = await parseXML(xmlData);
|
121 | 128 | |
122 | 129 | lazy.logConsole.debug("Loading search plugin");
|
... | ... | @@ -147,11 +154,13 @@ export async function loadAndParseOpenSearchEngine(sourceURI, lastModified) { |
147 | 154 | * The uri from which to load the OpenSearch engine data.
|
148 | 155 | * @param {string} [lastModified]
|
149 | 156 | * The UTC date when the engine was last updated, if any.
|
157 | + * @param {object} [originAttributes]
|
|
158 | + * The origin attributes to use to load the manifest.
|
|
150 | 159 | * @returns {Promise}
|
151 | 160 | * A promise that is resolved with the data if the engine is successfully loaded
|
152 | 161 | * and rejected otherwise.
|
153 | 162 | */
|
154 | -function loadEngineXML(sourceURI, lastModified) {
|
|
163 | +function loadEngineXML(sourceURI, lastModified, originAttributes = null) {
|
|
155 | 164 | var chan = lazy.SearchUtils.makeChannel(
|
156 | 165 | sourceURI,
|
157 | 166 | // OpenSearchEngine is loading a definition file for a search engine,
|
... | ... | @@ -164,6 +173,17 @@ function loadEngineXML(sourceURI, lastModified) { |
164 | 173 | ? Ci.nsILoadInfo.ALREADY_HTTPS
|
165 | 174 | : Ci.nsILoadInfo.NO_UPGRADE;
|
166 | 175 | |
176 | + if (!originAttributes) {
|
|
177 | + originAttributes = {};
|
|
178 | + try {
|
|
179 | + originAttributes.firstPartyDomain =
|
|
180 | + Services.eTLD.getSchemelessSite(sourceURI);
|
|
181 | + } catch (ex) {
|
|
182 | + console.error("Failed to get first party domain for the manifest", ex);
|
|
183 | + }
|
|
184 | + }
|
|
185 | + chan.loadInfo.originAttributes = originAttributes;
|
|
186 | + |
|
167 | 187 | if (lastModified && chan instanceof Ci.nsIHttpChannel) {
|
168 | 188 | chan.setRequestHeader("If-Modified-Since", lastModified, false);
|
169 | 189 | }
|
... | ... | @@ -762,13 +762,15 @@ export class SearchService { |
762 | 762 | });
|
763 | 763 | }
|
764 | 764 | |
765 | - async addOpenSearchEngine(engineURL, iconURL) {
|
|
765 | + async addOpenSearchEngine(engineURL, iconURL, originAttributes) {
|
|
766 | 766 | lazy.logConsole.debug("addOpenSearchEngine: Adding", engineURL);
|
767 | 767 | await this.init();
|
768 | 768 | let engine;
|
769 | 769 | try {
|
770 | 770 | let engineData = await lazy.loadAndParseOpenSearchEngine(
|
771 | - Services.io.newURI(engineURL)
|
|
771 | + Services.io.newURI(engineURL),
|
|
772 | + null,
|
|
773 | + originAttributes
|
|
772 | 774 | );
|
773 | 775 | engine = new lazy.OpenSearchEngine({ engineData, faviconURL: iconURL });
|
774 | 776 | } catch (ex) {
|
... | ... | @@ -340,10 +340,14 @@ interface nsISearchService : nsISupports |
340 | 340 | * icon. This value may be overridden by an icon specified in the
|
341 | 341 | * engine description file.
|
342 | 342 | *
|
343 | + * @param originAttributes [optional]
|
|
344 | + The origin attributes to use to load this manifest.
|
|
345 | + *
|
|
343 | 346 | * @throws NS_ERROR_FAILURE if the description file cannot be successfully
|
344 | 347 | * loaded.
|
345 | 348 | */
|
346 | - Promise addOpenSearchEngine(in AString engineURL, in AString iconURL);
|
|
349 | + Promise addOpenSearchEngine(in AString engineURL, in AString iconURL,
|
|
350 | + [optional] in jsval originAttributes);
|
|
347 | 351 | |
348 | 352 | /**
|
349 | 353 | * Adds a new search engine defined by the user.
|
... | ... | @@ -500,7 +500,13 @@ class TorDomainIsolatorImpl { |
500 | 500 | const browsers =
|
501 | 501 | channel.loadInfo.browsingContext?.topChromeWindow?.gBrowser?.browsers;
|
502 | 502 | if (!browsers || !channel.loadInfo.browsingContext?.browserId) {
|
503 | - logger.debug("Missing data to associate to a browser", channel.loadInfo);
|
|
503 | + if (channel instanceof Ci.nsIHttpChannel) {
|
|
504 | + logger.debug(
|
|
505 | + "Missing data to associate to a browser",
|
|
506 | + channel.loadInfo.loadingPrincipal?.URI?.spec,
|
|
507 | + channel.loadInfo
|
|
508 | + );
|
|
509 | + }
|
|
504 | 510 | return null;
|
505 | 511 | }
|
506 | 512 | for (const browser of browsers) {
|
... | ... | @@ -593,7 +599,7 @@ class TorDomainIsolatorImpl { |
593 | 599 | // Should we modify the lower layer to send a circuit identifier, instead?
|
594 | 600 | if (
|
595 | 601 | circuit.length === data.length &&
|
596 | - circuit.every((id, index) => id === data[index].fingerprint)
|
|
602 | + circuit.every((fp, index) => fp === data[index].fingerprint)
|
|
597 | 603 | ) {
|
598 | 604 | return;
|
599 | 605 | }
|