Pier Angelo Vendrame pushed to branch tor-browser-128.2.0esr-14.0-1 at The Tor Project / Applications / Tor Browser

Commits:

5 changed files:

Changes:

  • mobile/android/android-components/components/feature/search/src/main/assets/searchplugins/ddg-onion.xml
    ... ... @@ -3,9 +3,8 @@
    3 3
     <Description>Duck Duck Go Onion</Description>
    
    4 4
     <InputEncoding>UTF-8</InputEncoding>
    
    5 5
     <Image height="16" width="16">data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAB8lBMVEUAAADkRQzjPwPjQQXkRQ3iPwTiQQXgPQPeQgrcOwPVNgDVNQDWOgbTMwDRMgDQMwDSMwDRNwTQLgDRJgDSJwDSLgDSNwTjOgDiOADjOQDkPADhQAXzs5v+/fv////0vKbiRQvgPQHpdUr85NzuknPdKgDcIwDnZzj2w7HqeU/gPQLsimb/+PftjWn97Obpb0LdJQDeLQDtjmvsi2jgSBDnbULgOQD/39HgLQDeMgDpeFLgSBH0v670uqbaJQD2qImWvP/G1Ob5+/3u//+fvvXyp47dMwDaLwD0u6v0v6/aNQDiXi/aKQD3qozU7/8gSY2vvtg0ZK/OqLDaKQHYKgLgWTfaNADZMgDZMADZLADzqpD7//+xwdz//9H/5Bn/7Bn//ADofADYMADYMQDZOgPXLgDiZDj//97/0AD3tQDvlgHZOgbXLATXMADWMgDfXjLVLQD///z+0AD/3Rn/yRnwnQDcVjbVMQDyv67wuKTSJwDRHQD+8O/tg3/iQQDwhAHnawHWMADvtKfyva7XQxHga0bQGQD2vbH/u8LXIQCmPQzja07XQxLliGn99fPkcVHvhnGZ5VguvUU5wktBwCcAgxzydVv/8/XmiGngdlL+ysi3+I8LtCE80V6P3YmX4sDleljSNQLzr6D7sKPXNQTSIwAEAbMrAAAAF3RSTlMARqSkRvPz80PTpKRG3fPe3hio9/eoGP50jNsAAAABYktHRB5yCiArAAAAyElEQVQYGQXBvUqCYRiA4fu2V9Tn+UQddI3aCpxaOoU6iU4gcqqpoYbALXBuCuoYmttamqJDiEoh4YP+MOi6BNCh+uYKEGiOVNCXXxA2XDVV/UyfKbRCXTLQWAxbP2vt8Ue/uYDvfim91615sb2um6rqtrr/NFb1cUf1Ybd06areU6lSlYpK79jzK1SyJOkfhOl8JGEcqV5zoKrTRqO6yUzIzNu46ijdM1VV9bhuUJ/nZURExLRzUiPQm3kKXHi4BAEGOmOi78A/L1QoU/VHoTsAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTQtMDEtMTlUMjA6MDE6MTEtMDU6MDAuET6cAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE0LTAxLTE5VDIwOjAxOjExLTA1OjAwX0yGIAAAAABJRU5ErkJggg==</Image>
    
    6
    -<Url type="text/html" method="POST" template="https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion">
    
    6
    +<Url type="text/html" method="GET" template="https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/">
    
    7 7
       <Param name="q" value="{searchTerms}"/>
    
    8 8
     </Url>
    
    9 9
     <SearchForm>https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion</SearchForm>
    
    10 10
     </SearchPlugin>
    11
    -

  • mobile/android/android-components/components/feature/search/src/main/java/mozilla/components/feature/search/SearchUseCases.kt
    ... ... @@ -13,6 +13,8 @@ import mozilla.components.browser.state.state.SessionState
    13 13
     import mozilla.components.browser.state.state.selectedOrDefaultSearchEngine
    
    14 14
     import mozilla.components.browser.state.store.BrowserStore
    
    15 15
     import mozilla.components.concept.engine.EngineSession
    
    16
    +import mozilla.components.concept.engine.Settings
    
    17
    +import mozilla.components.concept.engine.UnsupportedSettingException
    
    16 18
     import mozilla.components.feature.search.ext.buildSearchUrl
    
    17 19
     import mozilla.components.feature.session.SessionUseCases
    
    18 20
     import mozilla.components.feature.tabs.TabsUseCases
    
    ... ... @@ -25,6 +27,7 @@ class SearchUseCases(
    25 27
         store: BrowserStore,
    
    26 28
         tabsUseCases: TabsUseCases,
    
    27 29
         sessionUseCases: SessionUseCases,
    
    30
    +    settings: Settings? = null,
    
    28 31
     ) {
    
    29 32
         interface SearchUseCase {
    
    30 33
             /**
    
    ... ... @@ -41,6 +44,7 @@ class SearchUseCases(
    41 44
             private val store: BrowserStore,
    
    42 45
             private val tabsUseCases: TabsUseCases,
    
    43 46
             private val sessionUseCases: SessionUseCases,
    
    47
    +        private val settings: Settings? = null,
    
    44 48
         ) : SearchUseCase {
    
    45 49
             private val logger = Logger("DefaultSearchUseCase")
    
    46 50
     
    
    ... ... @@ -72,9 +76,15 @@ class SearchUseCases(
    72 76
                 flags: EngineSession.LoadUrlFlags = EngineSession.LoadUrlFlags.none(),
    
    73 77
                 additionalHeaders: Map<String, String>? = null,
    
    74 78
             ) {
    
    79
    +            var securityLevel: Int
    
    80
    +            try {
    
    81
    +                securityLevel = settings?.torSecurityLevel ?: 0
    
    82
    +            } catch (e: UnsupportedSettingException) {
    
    83
    +                securityLevel = 0
    
    84
    +            }
    
    75 85
                 val searchUrl = searchEngine?.let {
    
    76
    -                searchEngine.buildSearchUrl(searchTerms)
    
    77
    -            } ?: store.state.search.selectedOrDefaultSearchEngine?.buildSearchUrl(searchTerms)
    
    86
    +                searchEngine.buildSearchUrl(searchTerms, securityLevel)
    
    87
    +            } ?: store.state.search.selectedOrDefaultSearchEngine?.buildSearchUrl(searchTerms, securityLevel)
    
    78 88
     
    
    79 89
                 if (searchUrl == null) {
    
    80 90
                     logger.warn("No default search engine available to perform search")
    
    ... ... @@ -124,6 +134,7 @@ class SearchUseCases(
    124 134
             private val store: BrowserStore,
    
    125 135
             private val tabsUseCases: TabsUseCases,
    
    126 136
             private val isPrivate: Boolean,
    
    137
    +        private val settings: Settings? = null,
    
    127 138
         ) : SearchUseCase {
    
    128 139
             private val logger = Logger("NewTabSearchUseCase")
    
    129 140
     
    
    ... ... @@ -161,9 +172,15 @@ class SearchUseCases(
    161 172
                 flags: EngineSession.LoadUrlFlags = EngineSession.LoadUrlFlags.none(),
    
    162 173
                 additionalHeaders: Map<String, String>? = null,
    
    163 174
             ) {
    
    175
    +            var securityLevel: Int
    
    176
    +            try {
    
    177
    +                securityLevel = settings?.torSecurityLevel ?: 0
    
    178
    +            } catch (e: UnsupportedSettingException) {
    
    179
    +                securityLevel = 0
    
    180
    +            }
    
    164 181
                 val searchUrl = searchEngine?.let {
    
    165
    -                searchEngine.buildSearchUrl(searchTerms)
    
    166
    -            } ?: store.state.search.selectedOrDefaultSearchEngine?.buildSearchUrl(searchTerms)
    
    182
    +                searchEngine.buildSearchUrl(searchTerms, securityLevel)
    
    183
    +            } ?: store.state.search.selectedOrDefaultSearchEngine?.buildSearchUrl(searchTerms, securityLevel)
    
    167 184
     
    
    168 185
                 if (searchUrl == null) {
    
    169 186
                     logger.warn("No default search engine available to perform search")
    
    ... ... @@ -310,15 +327,15 @@ class SearchUseCases(
    310 327
         }
    
    311 328
     
    
    312 329
         val defaultSearch: DefaultSearchUseCase by lazy {
    
    313
    -        DefaultSearchUseCase(store, tabsUseCases, sessionUseCases)
    
    330
    +        DefaultSearchUseCase(store, tabsUseCases, sessionUseCases, settings)
    
    314 331
         }
    
    315 332
     
    
    316 333
         val newTabSearch: NewTabSearchUseCase by lazy {
    
    317
    -        NewTabSearchUseCase(store, tabsUseCases, false)
    
    334
    +        NewTabSearchUseCase(store, tabsUseCases, false, settings)
    
    318 335
         }
    
    319 336
     
    
    320 337
         val newPrivateTabSearch: NewTabSearchUseCase by lazy {
    
    321
    -        NewTabSearchUseCase(store, tabsUseCases, true)
    
    338
    +        NewTabSearchUseCase(store, tabsUseCases, true, settings)
    
    322 339
         }
    
    323 340
     
    
    324 341
         val addSearchEngine: AddNewSearchEngineUseCase by lazy {
    

  • mobile/android/android-components/components/feature/search/src/main/java/mozilla/components/feature/search/ext/SearchEngine.kt
    ... ... @@ -85,9 +85,9 @@ fun SearchEngine.buildSuggestionsURL(query: String): String? {
    85 85
     /**
    
    86 86
      * Builds a URL to search for the given search terms with this search engine.
    
    87 87
      */
    
    88
    -fun SearchEngine.buildSearchUrl(searchTerm: String): String {
    
    88
    +fun SearchEngine.buildSearchUrl(searchTerm: String, securityLevel: Int = 0): String {
    
    89 89
         val builder = SearchUrlBuilder(this)
    
    90
    -    return builder.buildSearchUrl(searchTerm)
    
    90
    +    return builder.buildSearchUrl(searchTerm, securityLevel)
    
    91 91
     }
    
    92 92
     
    
    93 93
     /**
    

  • mobile/android/android-components/components/feature/search/src/main/java/mozilla/components/feature/search/internal/SearchUrlBuilder.kt
    ... ... @@ -28,9 +28,12 @@ private const val OS_PARAM_OPTIONAL = "\\{" + "(?:\\w+:)?\\w+?" + "\\}"
    28 28
     internal class SearchUrlBuilder(
    
    29 29
         private val searchEngine: SearchEngine,
    
    30 30
     ) {
    
    31
    -    fun buildSearchUrl(searchTerms: String): String {
    
    31
    +    fun buildSearchUrl(searchTerms: String, securityLevel: Int): String {
    
    32 32
             // The parser should have put the best URL for this device at the beginning of the list.
    
    33
    -        val template = searchEngine.resultUrls[0]
    
    33
    +        var template = searchEngine.resultUrls[0]
    
    34
    +        if (securityLevel == 1 && (searchEngine.id == "ddg" || searchEngine.id == "ddg-onion")) {
    
    35
    +            template = template.replaceFirst("/?", "/html/?")
    
    36
    +        }
    
    34 37
             return buildUrl(template, searchTerms)
    
    35 38
         }
    
    36 39
     
    

  • mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/UseCases.kt
    ... ... @@ -73,6 +73,7 @@ class UseCases(
    73 73
                 store,
    
    74 74
                 tabsUseCases,
    
    75 75
                 sessionUseCases,
    
    76
    +            engine.settings,
    
    76 77
             )
    
    77 78
         }
    
    78 79