Commit eef84e22 authored by Tails developers's avatar Tails developers
Browse files

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/bugfix/8036-workaround-for-localized-searchplugins' into testing
parents 89d94d8e 0f3a96c4
/var/lib/tails-user-session/browser-locale.js
\ No newline at end of file
......@@ -2,7 +2,7 @@
set -e
# Import exec_firefox()
# Import exec_firefox() and configure_best_tor_launcher_locale()
. /usr/local/lib/tails-shell-library/tor-browser.sh
# The Tor Browser hardcodes the default profile dir to ../.. from the
......@@ -24,7 +24,7 @@ IsRelative=1
Path=profile.default
EOF
mkdir -p "${HOME}"/.tor-launcher/TorBrowser/Data/Browser/profile.default/preferences
ln -s /var/lib/tails-user-session/tor-launcher-locale.js \
"${HOME}"/.tor-launcher/TorBrowser/Data/Browser/profile.default/preferences/0000locale.js
configure_best_tor_launcher_locale "${HOME}"/.tor-launcher/TorBrowser/Data/Browser/profile.default
fi
exec_firefox -app "${HOME}"/.tor-launcher/tor-launcher-standalone/application.ini
......@@ -11,7 +11,7 @@ export TEXTDOMAIN
PROFILE="${HOME}/.tor-browser/profile.default"
# Import exec_firefox()
# Import exec_firefox() and configure_best_tor_browser_locale()
. /usr/local/lib/tails-shell-library/tor-browser.sh
ask_for_confirmation() {
......@@ -30,12 +30,34 @@ tor_has_bootstrapped() {
sudo -n -u debian-tor /usr/local/sbin/tor-has-bootstrapped
}
# Workaround bug #8036 by copying any localized search plugins into
# the profile.
enable_localized_searchplugins() {
local locale plugin
locale=$(cat "${PROFILE}"/preferences/0000locale.js | \
sed 's@^pref("general\.useragent\.locale", "\([^"]*\)");$@\1@')
if [ "${locale}" = en-US ] || [ -e "${PROFILE}"/searchplugins ]; then
return
fi
# Fallback to a similar locale if there is no exact match
plugin="$(ls -1 "${TBB_INSTALL}"/distribution/searchplugins/locale/ | grep -m1 "^${locale}\(-[A-Z]\+\)\?$" || true)"
if [ -n "${plugin}" ]; then
mkdir -p "${PROFILE}"/searchplugins
# The plugins do not load if they are symlinks
cp --dereference "${TBB_INSTALL}"/distribution/searchplugins/locale/"${plugin}"/* "${PROFILE}"/searchplugins
fi
}
start_browser() {
if [ ! -d "${PROFILE}" ]; then
/usr/local/bin/generate-tor-browser-profile
fi
configure_best_tor_browser_locale "${PROFILE}"
# Workaround bug #8036
enable_localized_searchplugins
if [ -z "$XAUTHORITY" ]; then
XAUTHORITY=~/.Xauthority
export XAUTHORITY
......
......@@ -3,9 +3,57 @@
TBB_INSTALL=/usr/local/lib/tor-browser
TBB_PROFILE=/etc/tor-browser/profile
TBB_EXT=/usr/local/share/tor-browser-extensions
TOR_LAUNCHER_LOCALES_DIR=/usr/share/tor-launcher-standalone/chrome/locale
exec_firefox() {
LD_LIBRARY_PATH="${TBB_INSTALL}"
export LD_LIBRARY_PATH
exec "${TBB_INSTALL}"/firefox "${@}"
}
guess_best_tor_browser_locale() {
local long_locale short_locale
long_locale="$(echo ${LANG} | sed -e 's/\..*$//' -e 's/_/-/')"
short_locale="$(echo ${long_locale} | cut -d"-" -f1)"
if [ -e "${TBB_EXT}/langpack-${long_locale}@firefox.mozilla.org.xpi" ]; then
echo ${long_locale}
elif ls -1 "${TBB_EXT}" | grep -q "^langpack-${short_locale}\(-[A-Z]\+\)\?@firefox.mozilla.org.xpi$"; then
# If we use locale xx-YY and there is no langpack for xx nor
# xx-YY but there is one for xx-ZZ, then Firefox is smart
# enough to use the xx-ZZ langpack if we set the locale to xx.
echo ${short_locale}
else
echo en-US
fi
}
guess_best_tor_launcher_locale() {
local long_locale short_locale
long_locale="$(echo ${LANG} | sed -e 's/\..*$//' -e 's/_/-/')"
short_locale="$(echo ${long_locale} | cut -d"-" -f1)"
if [ -e "${TOR_LAUNCHER_LOCALES_DIR}/${long_locale}" ]; then
echo ${long_locale}
elif ls -1 "${TOR_LAUNCHER_LOCALES_DIR}" | grep -q "^${short_locale}\(-[A-Z]\+\)\?$"; then
# See comment in guess_best_firefox_locale()
echo ${short_locale}
else
echo en-US
fi
}
configure_xulrunner_app_locale() {
local profile locale
profile="${1}"
locale="${2}"
mkdir -p "${profile}"/preferences
echo "pref(\"general.useragent.locale\", \"${locale}\");" > \
"${profile}"/preferences/0000locale.js
}
configure_best_tor_browser_locale() {
configure_xulrunner_app_locale "${1}" "$(guess_best_tor_browser_locale)"
}
configure_best_tor_launcher_locale() {
configure_xulrunner_app_locale "${1}" "$(guess_best_tor_launcher_locale)"
}
......@@ -22,7 +22,9 @@ BROWSER_USER=i2pbrowser
TBB_PREFS="/etc/tor-browser/profile/preferences"
START_PAGE="http://127.0.0.1:7657"
# Import the TBB_INSTALL, TBB_EXT and TBB_PROFILE variables
# Import the TBB_INSTALL, TBB_EXT and TBB_PROFILE variables, and
# exec_firefox(), configure_xulrunner_app_locale() and
# guess_best_tor_browser_locale()
. /usr/local/lib/tails-shell-library/tor-browser.sh
NOSCRIPT="${TBB_EXT}/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi"
......@@ -109,18 +111,13 @@ setup_chroot () {
set_chroot_browser_name () {
NAME="${1}"
LONG=$(echo ${LANG} | grep -o "^[a-zA-Z_]*")
SHORT=${LONG%%_*}
EXT_DIR="${CHROOT}/${TBB_EXT}"
LOCALE="${2}"
EXT_DIR=${CHROOT}/"${TBB_EXT}"
BRANDING=branding/brand.dtd
if [ -e "${EXT_DIR}/langpack-${LONG}@firefox.mozilla.org.xpi" ]; then
PACK="${EXT_DIR}/langpack-${LONG}@firefox.mozilla.org.xpi"
if [ "${LOCALE}" != en-US ]; then
PACK="${EXT_DIR}/langpack-${LOCALE}@firefox.mozilla.org.xpi"
TOP=browser/chrome
REST=${LONG}/locale
elif [ -e "${EXT_DIR}/langpack-${SHORT}@firefox.mozilla.org.xpi" ]; then
PACK="${EXT_DIR}/langpack-${SHORT}@firefox.mozilla.org.xpi"
TOP=browser/chrome
REST=${SHORT}/locale
REST=${LOCALE}/locale
else
PACK="${CHROOT}/${TBB_INSTALL}/browser/omni.ja"
TOP=chrome
......@@ -174,8 +171,8 @@ configure_chroot () {
${BROWSER_PREF_DIR}/extension-overrides.js
# Localization
cat /var/lib/tails-user-session/browser-locale.js >> "${BROWSER_PREFS}"
BEST_LOCALE="$(guess_best_tor_browser_locale)"
configure_xulrunner_app_locale "${BROWSER_PROFILE}" "${BEST_LOCALE}"
# Prevent File -> Print or CTRL+P from causing the browser to hang
# for several minutes while trying to communicate with CUPS, since
......@@ -184,7 +181,7 @@ configure_chroot () {
${BROWSER_PREFS}
# Set the name (e.g. window title) of the browser
set_chroot_browser_name "`gettext \"I2P Browser\"`"
set_chroot_browser_name "`gettext \"I2P Browser\"`" "${BEST_LOCALE}"
# Set start page to the router console
echo 'user_pref("browser.startup.homepage", "'${START_PAGE}'");' >> \
......
......@@ -18,7 +18,9 @@ CLEARNET_USER=clearnet
# Import tor_is_working()
. /usr/local/lib/tails-shell-library/tor.sh
# Import the TBB_INSTALL, TBB_EXT and TBB_PROFILE variables
# Import the TBB_INSTALL, TBB_EXT and TBB_PROFILE variables, and
# exec_firefox(), configure_xulrunner_app_locale() and
# guess_best_tor_browser_locale()
. /usr/local/lib/tails-shell-library/tor-browser.sh
WARNING_PAGE='/usr/share/doc/tails/website/misc/unsafe_browser_warning'
......@@ -109,18 +111,13 @@ setup_chroot () {
set_chroot_browser_name () {
NAME="${1}"
LONG=$(echo ${LANG} | grep -o "^[a-zA-Z_]*")
SHORT=${LONG%%_*}
LOCALE="${2}"
EXT_DIR=${CHROOT}/"${TBB_EXT}"
BRANDING=branding/brand.dtd
if [ -e "${EXT_DIR}/langpack-${LONG}@firefox.mozilla.org.xpi" ]; then
PACK="${EXT_DIR}/langpack-${LONG}@firefox.mozilla.org.xpi"
if [ "${LOCALE}" != en-US ]; then
PACK="${EXT_DIR}/langpack-${LOCALE}@firefox.mozilla.org.xpi"
TOP=browser/chrome
REST=${LONG}/locale
elif [ -e "${EXT_DIR}/langpack-${SHORT}@firefox.mozilla.org.xpi" ]; then
PACK="${EXT_DIR}/langpack-${SHORT}@firefox.mozilla.org.xpi"
TOP=browser/chrome
REST=${SHORT}/locale
REST=${LOCALE}/locale
else
PACK="${CHROOT}/${TBB_INSTALL}/browser/omni.ja"
TOP=chrome
......@@ -165,7 +162,8 @@ configure_chroot () {
mkdir -p "$(dirname "${CLEARNET_PREFS}")"
# Localization
cat /var/lib/tails-user-session/browser-locale.js >> "${CLEARNET_PREFS}"
BEST_LOCALE="$(guess_best_tor_browser_locale)"
configure_xulrunner_app_locale "${CLEARNET_PROFILE}" "${BEST_LOCALE}"
# Disable proxying in the chroot
echo 'pref("network.proxy.type", 0);' >> "${CLEARNET_PREFS}"
......@@ -179,7 +177,7 @@ configure_chroot () {
echo 'user_pref("extensions.getAddons.showPane", false);' >> "${CLEARNET_PREFS}"
# Set the name (e.g. window title) of the browser
set_chroot_browser_name "`gettext \"Unsafe Browser\"`"
set_chroot_browser_name "`gettext \"Unsafe Browser\"`" "${BEST_LOCALE}"
# Set start page to something that explains what's going on
echo 'user_pref("browser.startup.homepage", "'${START_PAGE}'");' >> \
......
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