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

[tor-commits] [Git][tpo/applications/tor-browser][tor-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 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:

Changes:

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

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