Commit 2e84dad3 authored by intrigeri's avatar intrigeri

Drop search engine customization and stick to Tor Browser's defaults (refs: #15023)

This area has become a recurring PITA across major Firefox upgrades,
needing more and more hacks every time. Now it's broken again for ESR60.
Let's drop the ball: if we really need something special, we can talk
to the Tor Browser team..
parent 8b7dbd13
......@@ -197,36 +197,6 @@ EOF
rm -r "${tmp}"
}
# Modern Firefox doesn't apply browser.search.defaultenginename on
# start, and the other ways to get it to work (e.g. pre-generating
# search.json.mozlz4) seems rather complex. Instead, let's just make
# browser.search.defaultenginename work again by employing some
# Enterprise features to run arbitrary JavaScript with access to the
# Firefox internals. For the details of this feature, see:
# https://developer.mozilla.org/en-US/Firefox/Enterprise_deployment
apply_default_searchengine_hacks () {
local destination
destination="${1}"
cat > "${destination}/defaults/pref/autoconfig.js" <<EOF
// This file must start with a comment
pref("general.config.filename", "mozilla.cfg");
pref("general.config.obscure_value", 0);
EOF
cat > "${destination}/mozilla.cfg" <<EOF
// This file must start with a comment
var searchService = Components.classes["@mozilla.org/browser/search-service;1"].getService(Components.interfaces.nsIBrowserSearchService);
var engineName = getPref("browser.search.defaultenginename");
if (engineName) {
var engine = searchService.getEngineByName(engineName);
if (engine) {
searchService.currentEngine = engine;
}
}
EOF
}
apply_extension_prefs_hacks() {
local tbb_install tmp tbb_timestamp
tbb_install="${1}"
......@@ -333,7 +303,6 @@ download_and_verify_files "${TBB_TARBALLS_BASE_URL}" "${TBB_TARBALLS}" "${TMP}"
install_tor_browser "${TMP}/${MAIN_TARBALL}" "${TBB_INSTALL}"
apply_extension_code_signing_hacks "${TBB_INSTALL}"
apply_default_searchengine_hacks "${TBB_INSTALL}"
apply_extension_prefs_hacks "${TBB_INSTALL}"
strip_nondeterminism "${TBB_INSTALL}"
......
......@@ -19,7 +19,6 @@ echo "Localize each supported browser locale"
ensure_hook_dependency_is_installed p7zip imagemagick
TBB_LOCALIZED_SEARCHPLUGINS_DIR="${TBB_INSTALL}/distribution/searchplugins/locale/"
BROWSER_LOCALIZATION_DIR="/usr/share/tails/browser-localization"
DESCRIPTIONS_FILE="${BROWSER_LOCALIZATION_DIR}/descriptions"
LOCALE_PROFILES_DIR="/etc/tor-browser/locale-profiles/"
......@@ -34,7 +33,7 @@ for LOCALE in $(supported_tor_browser_locales); do
fi
done
if [ -n "${BROKEN_LOCALES}" ]; then
echo "The following supported browser locales lack search plugin descriptions in ${DESCRIPTIONS_FILE}:${BROKEN_LOCALES}" >&2
echo "The following supported browser locales lack descriptions in ${DESCRIPTIONS_FILE}:${BROKEN_LOCALES}" >&2
exit 1
fi
......@@ -64,58 +63,11 @@ while IFS=: read MOZILLA_LOCALE LOCATION LOCALIZED_LANG; do
NORMAL_LOCALE="${MOZILLA_LOCALE}_${LOCATION}"
fi
LANG_CODE="$(language_code_from_locale "${NORMAL_LOCALE}")"
TARGET_SEARCHPLUGINS_DIR="${TBB_LOCALIZED_SEARCHPLUGINS_DIR}/${MOZILLA_LOCALE}"
mkdir -p "${TARGET_SEARCHPLUGINS_DIR}"
DDG_PLUGIN="${TARGET_SEARCHPLUGINS_DIR}/ddg-${MOZILLA_LOCALE}.xml"
DDG_LANG_UI="${NORMAL_LOCALE}"
if [ "${DDG_LANG_UI}" = "vi_VN" ]; then
# DDG uses a non-standard locale for Vietnamese
DDG_LANG_UI="vi_VI"
fi
sed -e "s/\${LOCALIZED_LANG}/${LOCALIZED_LANG}/" \
-e "s/\${LANG_UI}/${DDG_LANG_UI}/" \
"${BROWSER_LOCALIZATION_DIR}/ddg.xml-template" > \
"${DDG_PLUGIN}"
# We generate a Wikipedia plugin with localized icons since we
# want to provide both English and the locale's plugin, and
# Firefox' new search bar only shows icons; the description (which
# is localized) is only shown in a pop-up nowdays, so it's easy to
# mix them up.
CAPITALIZED_LANG_CODE="$(echo "${LANG_CODE}" | tr 'a-z' 'A-Z')"
LOCALIZED_WIKIPEDIA_ICON_PATH="/tmp/wikipedia-icon-${LANG_CODE}.png"
WIKIPEDIA_SEARCH_ICON_BASE64_PATH="${LOCALIZED_WIKIPEDIA_ICON_PATH}.base64"
WIKIPEDIA_ICON_TEMPLATE="${BROWSER_LOCALIZATION_DIR}/Wikipedia-icon.png"
convert "${WIKIPEDIA_ICON_TEMPLATE}" \
-gravity SouthEast -pointsize 130 -font Liberation-Sans-Bold \
-fill black -annotate 0 "${CAPITALIZED_LANG_CODE}" \
+set date:create +set date:modify -define png:exclude-chunk=time \
-resize 16x16 "${LOCALIZED_WIKIPEDIA_ICON_PATH}"
base64 "${LOCALIZED_WIKIPEDIA_ICON_PATH}" | tr -d "\n" > \
"${WIKIPEDIA_SEARCH_ICON_BASE64_PATH}"
sed -e "s/\${LANG_CODE}/${LANG_CODE}/" \
-e "s/\${LOCALIZED_LANG}/${LOCALIZED_LANG}/" \
-e "/\${BASE64_PNG_16x16}/ r ${WIKIPEDIA_SEARCH_ICON_BASE64_PATH}" \
-e "/\${BASE64_PNG_16x16}/d" \
"${BROWSER_LOCALIZATION_DIR}/wikipedia.xml-template" > \
"${TARGET_SEARCHPLUGINS_DIR}/wikipedia-${MOZILLA_LOCALE}.xml"
rm "${LOCALIZED_WIKIPEDIA_ICON_PATH}" \
"${WIKIPEDIA_SEARCH_ICON_BASE64_PATH}"
# Our Tor Browser wrapper script will make use of the following
# per-locale profiles to set localized defaults for various prefs.
mkdir -p "${LOCALE_PROFILES_DIR}"
LOCALE_PROFILE_FILE="${LOCALE_PROFILES_DIR}/${MOZILLA_LOCALE}.js"
for KEY in browser.search.defaultenginename \
browser.search.selectedEngine; do
PLUGIN="DuckDuckGo - ${LOCALIZED_LANG}"
if ! grep -q "<ShortName>${PLUGIN}</ShortName>" "${DDG_PLUGIN}"; then
echo "Trying to make search plugin '${PLUGIN}' the default for ${MOZILLA_LOCALE} but it unexpectedly wasn't the one we generated earlier" >&2
exit 1
fi
set_mozilla_pref "${LOCALE_PROFILE_FILE}" "${KEY}" "\"${PLUGIN}\"" "user_pref"
done
TBB_DICTIONARIES_DIR="${TBB_INSTALL}/dictionaries"
unset SPELLCHECKER_LOCALE
for LOCALE in "${NORMAL_LOCALE}" "${LANG_CODE}"; do
......@@ -146,45 +98,6 @@ done < "${DESCRIPTIONS_FILE}"
# This directory is not needed after build time.
rm -r "${BROWSER_LOCALIZATION_DIR}"
# Remove unwanted browser search plugins bundled in the Tor Browser.
# Note for posterity: the searchplugins/list.txt file must not be
# removed! It must list the filename (excl. .xml) of each plugin
# present, otherwise they won't work. It's not a problem to list
# nonexisting ones, so as long as we delete plugins we do not have to
# alter it.
7z d -mtc=off -tzip "${TBB_INSTALL}/browser/omni.ja" \
'chrome/en-US/locale/browser/searchplugins/ddg*.xml' \
'chrome/en-US/locale/browser/searchplugins/wikipedia*.xml' \
'chrome/en-US/locale/browser/searchplugins/yahoo*.xml'
# For consistency, fixup the internal timestamps of these archives with
# the same ones used by the Tor Browser instead of SOURCE_DATE_EPOCH.
tbb_timestamp="$(date --date='2000-01-01 00:00:00' +%s)"
strip_nondeterminism_wrapper --type zip --timestamp "${tbb_timestamp}" \
"${TBB_INSTALL}/browser/omni.ja" 2>/dev/null
for pack in "${TBB_EXT}"/langpack-*.xpi; do
7z d -mtc=off -tzip "${pack}" \
'browser/chrome/*/locale/browser/searchplugins/ddg*.xml' \
'browser/chrome/*/locale/browser/searchplugins/wikipedia*.xml' \
'browser/chrome/*/locale/browser/searchplugins/yahoo*.xml'
strip_nondeterminism_wrapper --type zip --timestamp "${tbb_timestamp}" \
"${pack}" 2>/dev/null
done
# We want our localized English Wikipedia plugin to be available in
# all locales.
(
cd "${TBB_LOCALIZED_SEARCHPLUGINS_DIR}"
for dir in *; do
if [ -d "${dir}" ] && [ "${dir}" != en-US ]; then
(
cd "${dir}"
cp -a ../en-US/wikipedia-en-US.xml .
)
fi
done
)
# All generated and modified files must remain world-readable.
chmod -R a+rX "${TBB_LOCALIZED_SEARCHPLUGINS_DIR}" \
"${LOCALE_PROFILES_DIR}" \
chmod -R a+rX "${LOCALE_PROFILES_DIR}" \
"${TBB_EXT}"
......@@ -78,12 +78,6 @@ pref("browser.newtabpage.directory.ping", "");
// ... and disable the explanation shown the first time
pref("browser.newtabpage.introShown", true);
// Don't use geographically specific search prefs, like
// browser.search.*.US for US locales. Our generated localization
// profiles localizes search-engines in an incompatible but equivalent
// way.
pref("browser.search.geoSpecificDefaults", false);
// Without setting this, the Download Management page will not update
// the progress being made.
pref("browser.download.panel.shown", true);
......
<SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/">
<ShortName>DuckDuckGo - ${LOCALIZED_LANG}</ShortName>
<Description>Duck Duck Go - ${LOCALIZED_LANG}</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16">data:image/png;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAANcNAADXDQAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAJyDsJmlk8pf6+v3s/v7+++zr/fcnIOyzJyDsgCcg7CYAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAnIOwBJyDscCcg7PZttJ7/7Pfs//////++xO7/S5GA/ycg7P8n
IOz2JyDscCcg7AEAAAAAAAAAAAAAAAAnIOwBJyDstScg7P8nIOz/Y8p5/2fHZf9Yv0z/YcF2/1rB
Uv8nIOz/JyDs/ycg7P8nIOy1JyDsAQAAAAAAAAAAJyDscCcg7P8nIOz/JyDs/4jQoP/p9+n/////
/05X3v9LkYD/JyDs/ycg7P8nIOz/JyDs/ycg7HAAAAAAJyDsJicg7PYnIOz/JyDs/zUu7f/+/v//
//////////89N+7/JyDs/yUo7f8nIOz/JyDs/ycg7P8nIOz2JyDsJicg7IAnIOz/JyDs/ycg7P9h
XPH////////////t/P//GIr2/wfD+/8Gyfz/DKv5/yM57/8nIOz/JyDs/ycg7H8nIOyzJyDs/ycg
7P8nIOz/jov1////////////Otz9/w3G/P8cWfH/JSvt/ycg7P8nIOz/JyDs/ycg7P8nIOyzJyDs
5icg7P8nIOz/JyDs/7u5+f///////////27l/v8E0v3/BNL9/wTQ/f8Oofn/IT7v/ycg7P8nIOz/
JyDs5icg7OYnIOz/JyDs/ycg7P/p6P3/uWsC////////////5fr//6Po/f8Thfb/DKv5/w6f+f8n IOz/JyDs/ycg7OYnIOyzJyDs/ycg7P8nIOz/9/b+/////////////////7lrAv/V1Pv/JyDs/ycg
7P8nIOz/JyDs/ycg7P8nIOyzJyDsgCcg7P8nIOz/JyDs/8/N+///////////////////////iIX1
/ycg7P8nIOz/JyDs/ycg7P8nIOz/JyDsfycg7CYnIOz2JyDs/ycg7P9FP+7/q6n4/+7u/f/n5v3/
fXn0/yoj7P8nIOz/JyDs/ycg7P8nIOz/JyDs9icg7CYAAAAAJyDscCcg7P8nIOz/wsD6/+no/f/Y
1/z/eHTz/ycg7P8nIOz/JyDs/ycg7P8nIOz/JyDs/ycg7HAAAAAAAAAAACcg7AEnIOy1JyDs/ycg
7P8nIOz/JyDs/ycg7P8nIOz/JyDs/ycg7P8nIOz/JyDs/ycg7LUnIOwBAAAAAAAAAAAAAAAAJyDs
AScg7HAnIOz2JyDs/ycg7P8nIOz/JyDs/ycg7P8nIOz/JyDs9icg7HAnIOwBAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAJyDsJicg7IAnIOyzJyDs5icg7OYnIOyzJyDsgCcg7CYAAAAAAAAAAAAAAAAA
AAAA+B8AAPAPAADAAwAAwAMAAIABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAACAAQAAwAMAAMAD
AADwDwAA+B8AAA==</Image>
<Url type="text/html" method="GET" template="https://duckduckgo.com/">
<Param name="kad" value="${LANG_UI}"/>
<Param name="q" value="{searchTerms}"/>
</Url>
<SearchForm>https://duckduckgo.com/</SearchForm>
</SearchPlugin>
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Wikipedia - ${LOCALIZED_LANG}</ShortName>
<LongName>Wikipedia - ${LOCALIZED_LANG}</LongName>
<Description>Wikipedia - ${LOCALIZED_LANG}</Description>
<Url type="text/html" method="GET" template="http://${LANG_CODE}.wikipedia.org/" resultdomain="wikipedia.org" rel="searchform">
<Param name="search" value="{searchTerms}"/>
<Param name="sourceid" value="Mozilla-search"/>
</Url>
<Image height="16" width="16">data:image/png;base64,
${BASE64_PNG_16x16}
</Image>
</OpenSearchDescription>
......@@ -351,28 +351,6 @@ You *really* have to reboot between each language.
Russian, Tiếng Việt).
* In the Tor Browser:
- DuckDuckGo must be the default, pre-selected search plugin. (automate: [[!tails_ticket 10265]])
- the search plugins must be localized for the expected locales
(automate: [[!tails_ticket 10267]]).
StartPage should have localized *user interface* for (run this in
a Tails Git checkout of the commit the release under testing was built
from):
grep --extended-regexp "[^:]*:[^:]*:[^:]*:[^:]*:[^:]+" \
config/chroot_local-includes/usr/share/tails/browser-localization/descriptions | \
sed -n --regexp-extended 's/^([^:]+):.*$/\1/p'
StartPage should have localized *search results* for:
grep --extended-regexp "[^:]*:[^:]*:[^:]*:[^:]+:[^:]*" \
config/chroot_local-includes/usr/share/tails/browser-localization/descriptions | \
sed -n --regexp-extended 's/^([^:]+):.*$/\1/p'
DDG should have localized user interface *and* search results, and
Wikipedia should have a localized plugin, for:
sed -n --regexp-extended 's/^([^:]+):.*$/\1/p' \
config/chroot_local-includes/usr/share/tails/browser-localization/descriptions
## Spellchecking
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment