Pier Angelo Vendrame pushed to branch tor-browser-115.1.0esr-13.0-1 at The Tor Project / Applications / Tor Browser
Commits: 76d4d68d by Pier Angelo Vendrame at 2023-08-16T19:44:37+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 ===================================== @@ -2704,6 +2704,7 @@ export class SearchService { };
let engines = []; + let revert = false; for (let locale of locales) { lazy.logConsole.debug( "addEnginesFromExtension: installing:", @@ -2711,7 +2712,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/76d4d68d...
tbb-commits@lists.torproject.org