[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][base-browser-115.1.0esr-13.0-1] Bug 42022: Prevent extension search engines from breaking the whole search system



Title: GitLab

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:

Changes:

  • toolkit/components/search/SearchService.sys.mjs
    ... ... @@ -2706,6 +2706,7 @@ export class SearchService {
    2706 2706
         };
    
    2707 2707
     
    
    2708 2708
         let engines = [];
    
    2709
    +    let revert = false;
    
    2709 2710
         for (let locale of locales) {
    
    2710 2711
           lazy.logConsole.debug(
    
    2711 2712
             "addEnginesFromExtension: installing:",
    
    ... ... @@ -2713,7 +2714,28 @@ export class SearchService {
    2713 2714
             ":",
    
    2714 2715
             locale
    
    2715 2716
           );
    
    2716
    -      engines.push(await installLocale(locale));
    
    2717
    +      try {
    
    2718
    +        engines.push(await installLocale(locale));
    
    2719
    +      } catch (err) {
    
    2720
    +        lazy.logConsole.error(
    
    2721
    +          `Could not install the search engine of ${extension.id}`,
    
    2722
    +          err
    
    2723
    +        );
    
    2724
    +        revert = true;
    
    2725
    +        break;
    
    2726
    +      }
    
    2727
    +    }
    
    2728
    +    if (revert) {
    
    2729
    +      for (let engine of engines) {
    
    2730
    +        try {
    
    2731
    +          this.removeEngine(engine);
    
    2732
    +        } catch (err) {
    
    2733
    +          lazy.logConsole.warn(
    
    2734
    +            "Failed to revert the addition of a search engine",
    
    2735
    +            err
    
    2736
    +          );
    
    2737
    +        }
    
    2738
    +      }
    
    2717 2739
         }
    
    2718 2740
         return engines;
    
    2719 2741
       }
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits