[tbb-commits] [Git][tpo/applications/tor-browser][tor-browser-128.2.0esr-14.0-1] 2 commits: fixup! Bug 40009: [android] Change the default search engines
Pier Angelo Vendrame (@pierov)
git at gitlab.torproject.org
Thu Sep 12 19:06:53 UTC 2024
Pier Angelo Vendrame pushed to branch tor-browser-128.2.0esr-14.0-1 at The Tor Project / Applications / Tor Browser
Commits:
f52fcb50 by cypherpunks1 at 2024-09-12T19:06:14+00:00
fixup! Bug 40009: [android] Change the default search engines
Bug 43128: Make the ddg-onion search plugin consistent with ddg
- - - - -
cf07aee1 by cypherpunks1 at 2024-09-12T19:06:14+00:00
fixup! Bug 40925: Implemented the Security Level component
Bug 43128: Use DuckDuckGo HTML on the Safest security level for Android
- - - - -
5 changed files:
- mobile/android/android-components/components/feature/search/src/main/assets/searchplugins/ddg-onion.xml
- mobile/android/android-components/components/feature/search/src/main/java/mozilla/components/feature/search/SearchUseCases.kt
- mobile/android/android-components/components/feature/search/src/main/java/mozilla/components/feature/search/ext/SearchEngine.kt
- mobile/android/android-components/components/feature/search/src/main/java/mozilla/components/feature/search/internal/SearchUrlBuilder.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/UseCases.kt
Changes:
=====================================
mobile/android/android-components/components/feature/search/src/main/assets/searchplugins/ddg-onion.xml
=====================================
@@ -3,9 +3,8 @@
<Description>Duck Duck Go Onion</Description>
<InputEncoding>UTF-8</InputEncoding>
<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>
-<Url type="text/html" method="POST" template="https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion">
+<Url type="text/html" method="GET" template="https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion/">
<Param name="q" value="{searchTerms}"/>
</Url>
<SearchForm>https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion</SearchForm>
</SearchPlugin>
-
=====================================
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
import mozilla.components.browser.state.state.selectedOrDefaultSearchEngine
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.engine.EngineSession
+import mozilla.components.concept.engine.Settings
+import mozilla.components.concept.engine.UnsupportedSettingException
import mozilla.components.feature.search.ext.buildSearchUrl
import mozilla.components.feature.session.SessionUseCases
import mozilla.components.feature.tabs.TabsUseCases
@@ -25,6 +27,7 @@ class SearchUseCases(
store: BrowserStore,
tabsUseCases: TabsUseCases,
sessionUseCases: SessionUseCases,
+ settings: Settings? = null,
) {
interface SearchUseCase {
/**
@@ -41,6 +44,7 @@ class SearchUseCases(
private val store: BrowserStore,
private val tabsUseCases: TabsUseCases,
private val sessionUseCases: SessionUseCases,
+ private val settings: Settings? = null,
) : SearchUseCase {
private val logger = Logger("DefaultSearchUseCase")
@@ -72,9 +76,15 @@ class SearchUseCases(
flags: EngineSession.LoadUrlFlags = EngineSession.LoadUrlFlags.none(),
additionalHeaders: Map<String, String>? = null,
) {
+ var securityLevel: Int
+ try {
+ securityLevel = settings?.torSecurityLevel ?: 0
+ } catch (e: UnsupportedSettingException) {
+ securityLevel = 0
+ }
val searchUrl = searchEngine?.let {
- searchEngine.buildSearchUrl(searchTerms)
- } ?: store.state.search.selectedOrDefaultSearchEngine?.buildSearchUrl(searchTerms)
+ searchEngine.buildSearchUrl(searchTerms, securityLevel)
+ } ?: store.state.search.selectedOrDefaultSearchEngine?.buildSearchUrl(searchTerms, securityLevel)
if (searchUrl == null) {
logger.warn("No default search engine available to perform search")
@@ -124,6 +134,7 @@ class SearchUseCases(
private val store: BrowserStore,
private val tabsUseCases: TabsUseCases,
private val isPrivate: Boolean,
+ private val settings: Settings? = null,
) : SearchUseCase {
private val logger = Logger("NewTabSearchUseCase")
@@ -161,9 +172,15 @@ class SearchUseCases(
flags: EngineSession.LoadUrlFlags = EngineSession.LoadUrlFlags.none(),
additionalHeaders: Map<String, String>? = null,
) {
+ var securityLevel: Int
+ try {
+ securityLevel = settings?.torSecurityLevel ?: 0
+ } catch (e: UnsupportedSettingException) {
+ securityLevel = 0
+ }
val searchUrl = searchEngine?.let {
- searchEngine.buildSearchUrl(searchTerms)
- } ?: store.state.search.selectedOrDefaultSearchEngine?.buildSearchUrl(searchTerms)
+ searchEngine.buildSearchUrl(searchTerms, securityLevel)
+ } ?: store.state.search.selectedOrDefaultSearchEngine?.buildSearchUrl(searchTerms, securityLevel)
if (searchUrl == null) {
logger.warn("No default search engine available to perform search")
@@ -310,15 +327,15 @@ class SearchUseCases(
}
val defaultSearch: DefaultSearchUseCase by lazy {
- DefaultSearchUseCase(store, tabsUseCases, sessionUseCases)
+ DefaultSearchUseCase(store, tabsUseCases, sessionUseCases, settings)
}
val newTabSearch: NewTabSearchUseCase by lazy {
- NewTabSearchUseCase(store, tabsUseCases, false)
+ NewTabSearchUseCase(store, tabsUseCases, false, settings)
}
val newPrivateTabSearch: NewTabSearchUseCase by lazy {
- NewTabSearchUseCase(store, tabsUseCases, true)
+ NewTabSearchUseCase(store, tabsUseCases, true, settings)
}
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? {
/**
* Builds a URL to search for the given search terms with this search engine.
*/
-fun SearchEngine.buildSearchUrl(searchTerm: String): String {
+fun SearchEngine.buildSearchUrl(searchTerm: String, securityLevel: Int = 0): String {
val builder = SearchUrlBuilder(this)
- return builder.buildSearchUrl(searchTerm)
+ return builder.buildSearchUrl(searchTerm, securityLevel)
}
/**
=====================================
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+?" + "\\}"
internal class SearchUrlBuilder(
private val searchEngine: SearchEngine,
) {
- fun buildSearchUrl(searchTerms: String): String {
+ fun buildSearchUrl(searchTerms: String, securityLevel: Int): String {
// The parser should have put the best URL for this device at the beginning of the list.
- val template = searchEngine.resultUrls[0]
+ var template = searchEngine.resultUrls[0]
+ if (securityLevel == 1 && (searchEngine.id == "ddg" || searchEngine.id == "ddg-onion")) {
+ template = template.replaceFirst("/?", "/html/?")
+ }
return buildUrl(template, searchTerms)
}
=====================================
mobile/android/fenix/app/src/main/java/org/mozilla/fenix/components/UseCases.kt
=====================================
@@ -73,6 +73,7 @@ class UseCases(
store,
tabsUseCases,
sessionUseCases,
+ engine.settings,
)
}
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/6a5b1bc7a0ea3ef35c60713b140a5c9b03752dad...cf07aee1e3754bac699ef332b3bc977be4b80cec
--
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/6a5b1bc7a0ea3ef35c60713b140a5c9b03752dad...cf07aee1e3754bac699ef332b3bc977be4b80cec
You're receiving this email because of your account on gitlab.torproject.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20240912/4933c421/attachment-0001.htm>
More information about the tbb-commits
mailing list