Pier Angelo Vendrame pushed to branch base-browser-115.1.0esr-13.0-1 at The Tor Project / Applications / Tor Browser
Commits: d11b0294 by Pier Angelo Vendrame at 2023-08-16T19:44:09+02:00 Bug 42022: Prevent extension search engines from breaking the whole search system
We found that if an extension tries to add a search engine that is already bundled the whole search system breaks because an exception is thrown and it reaches the initialization function, whose catch undoes the initialization.
With this commit, we handle this kind of exceptions when trying to install the extension's engines, and contain it there.
- - - - -
1 changed file:
- toolkit/components/search/SearchService.sys.mjs
Changes:
===================================== toolkit/components/search/SearchService.sys.mjs ===================================== @@ -2706,6 +2706,7 @@ export class SearchService { };
let engines = []; + let revert = false; for (let locale of locales) { lazy.logConsole.debug( "addEnginesFromExtension: installing:", @@ -2713,7 +2714,28 @@ export class SearchService { ":", locale ); - engines.push(await installLocale(locale)); + try { + engines.push(await installLocale(locale)); + } catch (err) { + lazy.logConsole.error( + `Could not install the search engine of ${extension.id}`, + err + ); + revert = true; + break; + } + } + if (revert) { + for (let engine of engines) { + try { + this.removeEngine(engine); + } catch (err) { + lazy.logConsole.warn( + "Failed to revert the addition of a search engine", + err + ); + } + } } return engines; }
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/d11b0294...
tbb-commits@lists.torproject.org