tbb-commits
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 1 participants
- 18563 discussions

[tor-browser-build/master] Bug 28803: Integrate building Pluggable Transports for Android
by gk@torproject.org 07 Nov '19
by gk@torproject.org 07 Nov '19
07 Nov '19
commit eee5d30a9ab1d727caac262cb62f72aaab75e0a0
Author: Matthew Finkel <sysrqb(a)torproject.org>
Date: Thu Oct 31 01:52:21 2019 +0000
Bug 28803: Integrate building Pluggable Transports for Android
We integrate building Pluggable Transports for Android to solve #32303
in particular later on but it is important for providing snowflake
support as well at some point (see: #28672)
The bulk of the patch got written by boklm when trying to provide
snowflake support for Android (#28672).
---
.../go/0001-Use-fixed-go-build-tmp-directory.patch | 33 ++++++++++++++++++++
projects/go/build | 12 ++++----
projects/go/config | 30 +++++++++++++++++--
projects/gobsaes/config | 9 ++++++
...BILE_TMPDIR-env-variable-is-defined-use-t.patch | 35 ++++++++++++++++++++++
projects/gomobile/config | 33 ++++++++++++++++++++
projects/goptlib/config | 8 +++++
projects/goutls/config | 9 ++++++
projects/goxexp/config | 19 ++++++++++++
projects/goximage/config | 28 +++++++++++++++++
projects/goxnet/config | 9 ++++++
projects/obfs4/build | 4 +++
projects/obfs4/config | 3 ++
projects/tor-onion-proxy-library/build | 10 +++++++
projects/tor-onion-proxy-library/config | 2 ++
rbm.conf | 6 ++++
16 files changed, 241 insertions(+), 9 deletions(-)
diff --git a/projects/go/0001-Use-fixed-go-build-tmp-directory.patch b/projects/go/0001-Use-fixed-go-build-tmp-directory.patch
new file mode 100644
index 0000000..a10e059
--- /dev/null
+++ b/projects/go/0001-Use-fixed-go-build-tmp-directory.patch
@@ -0,0 +1,33 @@
+From 44e3391a5a3d9a2c4b57f78e43414465ab84681e Mon Sep 17 00:00:00 2001
+From: Nicolas Vigier <boklm(a)torproject.org>
+Date: Thu, 27 Jun 2019 19:21:05 +0200
+Subject: [PATCH] Use fixed go-build tmp directory
+
+Use fixed go-build tmp directory, when the directory does not exist, in
+order to avoid some reproducibility issues where build directory gets
+embedded in generated binaries.
+---
+ src/cmd/go/internal/work/action.go | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go
+index 1f91046eb1..ba74b26a38 100644
+--- a/src/cmd/go/internal/work/action.go
++++ b/src/cmd/go/internal/work/action.go
+@@ -224,9 +224,13 @@ func (b *Builder) Init() {
+ if cfg.BuildN {
+ b.WorkDir = "$WORK"
+ } else {
+- tmp, err := ioutil.TempDir(os.Getenv("GOTMPDIR"), "go-build")
+- if err != nil {
+- base.Fatalf("go: creating work dir: %v", err)
++ tmp := filepath.Join(os.Getenv("GOTMPDIR"), "go-build-workdir")
++ _, err := os.Stat(tmp)
++ if !os.IsNotExist(err) {
++ tmp, err = ioutil.TempDir(os.Getenv("GOTMPDIR"), "go-build")
++ if err != nil {
++ base.Fatalf("go: creating work dir: %v", err)
++ }
+ }
+ if !filepath.IsAbs(tmp) {
+ abs, err := filepath.Abs(tmp)
diff --git a/projects/go/build b/projects/go/build
index 4945c88..aa092d6 100644
--- a/projects/go/build
+++ b/projects/go/build
@@ -28,6 +28,9 @@ export GOROOT_BOOTSTRAP="/var/tmp/build/go1.4"
cd $rootdir
[% IF ! c("var/linux") %]
[% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
+ # http://golang.org/doc/install/source#environment
+ export GOOS=[% c("var/GOOS") %]
+ export GOARCH=[% c("var/GOARCH") %]
[% END %]
# Building go
@@ -48,9 +51,6 @@ cd /var/tmp/dist/go/src
echo "#!/bin/sh" > "$CC_FOR_TARGET"
echo "exec $CC $CFLAGS $LDFLAGS \"\$@\"" >> "$CC_FOR_TARGET"
chmod +x "$CC_FOR_TARGET"
- # http://golang.org/doc/install/source#environment
- export GOOS=darwin
- export GOARCH=amd64
# faketime is needed because clang 3.9.1 on Darwin embeds the timestamps of
# certain intermediate object files (including those that arise here while
# compiling the Go runtime itself). Without this, variable timestamps would
@@ -65,10 +65,10 @@ cd /var/tmp/dist/go/src
echo "#!/bin/sh" > "$CC_FOR_TARGET"
echo "exec [% c("arch") %]-w64-mingw32-gcc [% c("var/CFLAGS") %] [% c("var/LDFLAGS") %] \"\$@\"" >> "$CC_FOR_TARGET"
chmod +x "$CC_FOR_TARGET"
- # http://golang.org/doc/install/source#environment
- export GOOS=windows
- export GOARCH=[% c("var/GOARCH") %]
CGO_ENABLED=1 CC_FOR_TARGET="$CC_FOR_TARGET" CC= CFLAGS= LDFLAGS= ./make.bash
+[% ELSIF c("var/android") -%]
+ patch -p2 < $rootdir/0001-Use-fixed-go-build-tmp-directory.patch
+ CGO_ENABLED=1 CC_FOR_TARGET=[% c("var/CC") %] CGO_CFLAGS='-D__ANDROID_API__=[% c("var/android_min_api") %]' CC= CFLAGS= LDFLAGS= ./make.bash
[% END -%]
cd /var/tmp/dist
diff --git a/projects/go/config b/projects/go/config
index ffe07ea..31c510a 100644
--- a/projects/go/config
+++ b/projects/go/config
@@ -10,8 +10,13 @@ var:
setup: |
mkdir -p /var/tmp/dist
tar -C /var/tmp/dist -xf $rootdir/[% c("go_tarfile") %]
- export GOOS=[% c("var/GOOS") %]
- export GOARCH=[% c("var/GOARCH") %]
+ [% IF pc(c("origin_project"), "var/no_crosscompile") -%]
+ export GOOS=linux
+ export GOARCH=amd64
+ [% ELSE -%]
+ export GOOS=[% c("var/GOOS") %]
+ export GOARCH=[% c("var/GOARCH") %]
+ [% END -%]
export GOPATH=/var/tmp/dist/gopath
export PATH=/var/tmp/dist/go/bin:/var/tmp/dist/gopath/bin:"$PATH"
[% IF c("var/linux") -%]
@@ -21,6 +26,8 @@ var:
[% IF c("var/linux-i686") -%]
export CGO_ENABLED=1
[% END -%]
+ export GOTMPDIR=/var/tmp/build/go-tmp
+ mkdir -p "$GOTMPDIR"
# Template build script for building a go library.
# This can be called as projects/go/var/build_go_lib.
@@ -82,15 +89,32 @@ targets:
linux-i686:
var:
GOARCH: 386
+ android:
+ var:
+ GOOS: android
+ android-x86:
+ var:
+ GOARCH: 386
+ android-x86_64:
+ var:
+ GOARCH: amd64
+ android-armv7:
+ var:
+ GOARCH: arm
+ android-aarch64:
+ var:
+ GOARCH: arm64
input_files:
- project: container-image
- name: '[% c("var/compiler") %]'
project: '[% c("var/compiler") %]'
- enable: '[% c("var/windows") || c("var/osx") %]'
+ enable: '[% ! c("var/linux") %]'
- URL: 'https://golang.org/dl/go[% c("version") %].src.tar.gz'
name: go
sha256sum: ab0e56ed9c4732a653ed22e232652709afbf573e710f56a07f7fdeca578d62fc
- URL: 'https://golang.org/dl/go[% c("var/go14_version") %].src.tar.gz'
name: go14
sha256sum: 9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959
+ - filename: 0001-Use-fixed-go-build-tmp-directory.patch
+ enable: '[% c("var/android") %]'
diff --git a/projects/gobsaes/config b/projects/gobsaes/config
index 4da5828..0ced258 100644
--- a/projects/gobsaes/config
+++ b/projects/gobsaes/config
@@ -11,7 +11,16 @@ var:
use_container: 1
go_lib: git.schwanenlied.me/yawning/bsaes.git
+targets:
+ android:
+ var:
+ build_go_lib_pre: |
+ [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
+
input_files:
- project: container-image
- name: go
project: go
+ - name: '[% c("var/compiler") %]'
+ project: '[% c("var/compiler") %]'
+ enable: '[% c("var/android") %]'
diff --git a/projects/gomobile/0001-If-the-GOMOBILE_TMPDIR-env-variable-is-defined-use-t.patch b/projects/gomobile/0001-If-the-GOMOBILE_TMPDIR-env-variable-is-defined-use-t.patch
new file mode 100644
index 0000000..770b22a
--- /dev/null
+++ b/projects/gomobile/0001-If-the-GOMOBILE_TMPDIR-env-variable-is-defined-use-t.patch
@@ -0,0 +1,35 @@
+From 188307b6acd5003e82cb68872da9463f5f707515 Mon Sep 17 00:00:00 2001
+From: Nicolas Vigier <boklm(a)torproject.org>
+Date: Thu, 27 Jun 2019 12:46:38 +0200
+Subject: [PATCH] If the GOMOBILE_TMPDIR env variable is defined, use that as
+ tmpdir
+
+Having the option to select a fixed tmpdir makes it possible to have
+reproducible builds, as the build directory is embedded in the generated
+executables.
+---
+ cmd/gomobile/env.go | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
+index 471b009..b97141b 100644
+--- a/cmd/gomobile/env.go
++++ b/cmd/gomobile/env.go
+@@ -61,9 +61,14 @@ func buildEnvInit() (cleanup func(), err error) {
+ tmpdir = "$WORK"
+ cleanupFn = func() {}
+ } else {
+- tmpdir, err = ioutil.TempDir("", "gomobile-work-")
+- if err != nil {
+- return nil, err
++ gomobile_tmpdir := os.Getenv("GOMOBILE_TMPDIR")
++ if gomobile_tmpdir != "" {
++ tmpdir = gomobile_tmpdir
++ } else {
++ tmpdir, err = ioutil.TempDir("", "gomobile-work-")
++ if err != nil {
++ return nil, err
++ }
+ }
+ }
+ if buildX {
diff --git a/projects/gomobile/config b/projects/gomobile/config
new file mode 100644
index 0000000..9dbfc29
--- /dev/null
+++ b/projects/gomobile/config
@@ -0,0 +1,33 @@
+# vim: filetype=yaml sw=2
+version: '[% c("abbrev") %]'
+git_url: https://github.com/golang/mobile
+git_hash: 92f3b9caf7ba8f4f9c10074225afcba0cba47a62
+filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
+
+build: '[% c("projects/go/var/build_go_lib") %]'
+
+var:
+ container:
+ use_container: 1
+ no_crosscompile: 1
+ go_lib: golang.org/x/mobile
+ go_lib_deps:
+ - goximage
+ - goxexp
+ go_lib_install:
+ - golang.org/x/mobile/cmd/gobind
+ - golang.org/x/mobile/cmd/gomobile
+ build_go_lib_pre: |
+ [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
+
+input_files:
+ - project: container-image
+ - name: go
+ project: go
+ - name: goximage
+ project: goximage
+ - name: goxexp
+ project: goxexp
+ - name: '[% c("var/compiler") %]'
+ project: '[% c("var/compiler") %]'
+ - filename: 0001-If-the-GOMOBILE_TMPDIR-env-variable-is-defined-use-t.patch
diff --git a/projects/goptlib/config b/projects/goptlib/config
index 8c2a95d..4dfc6ff 100644
--- a/projects/goptlib/config
+++ b/projects/goptlib/config
@@ -18,7 +18,15 @@ targets:
version: master
tag_gpg_id: 0
+ android:
+ var:
+ build_go_lib_pre: |
+ [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
+
input_files:
- project: container-image
- name: go
project: go
+ - name: '[% c("var/compiler") %]'
+ project: '[% c("var/compiler") %]'
+ enable: '[% c("var/android") %]'
diff --git a/projects/goutls/config b/projects/goutls/config
index fa4b5d8..7a46517 100644
--- a/projects/goutls/config
+++ b/projects/goutls/config
@@ -17,6 +17,12 @@ var:
- gocompress
- gobsaes
+targets:
+ android:
+ var:
+ build_go_lib_pre: |
+ [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
+
input_files:
- project: container-image
- name: go
@@ -28,3 +34,6 @@ input_files:
- name: gobsaes
project: gobsaes
- filename: sessionid.patch
+ - name: '[% c("var/compiler") %]'
+ project: '[% c("var/compiler") %]'
+ enable: '[% c("var/android") %]'
diff --git a/projects/goxexp/config b/projects/goxexp/config
new file mode 100644
index 0000000..c81a65f
--- /dev/null
+++ b/projects/goxexp/config
@@ -0,0 +1,19 @@
+# vim: filetype=yaml sw=2
+version: '[% c("abbrev") %]'
+git_url: https://github.com/golang/exp
+git_hash: a1d7652674e8f269b17d9be90d3c4c1d0e8830e8
+filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
+
+build: '[% c("projects/go/var/build_go_lib") %]'
+
+var:
+ container:
+ use_container: 1
+ no_crosscompile: 1
+ go_lib: golang.org/x/exp
+ go_lib_install: []
+
+input_files:
+ - project: container-image
+ - name: go
+ project: go
diff --git a/projects/goximage/config b/projects/goximage/config
new file mode 100644
index 0000000..308a1ba
--- /dev/null
+++ b/projects/goximage/config
@@ -0,0 +1,28 @@
+# vim: filetype=yaml sw=2
+version: '[% c("abbrev") %]'
+git_url: https://github.com/golang/image
+git_hash: 0694c2d4d067f97ebef574d63a763ee8ab559da7
+filename: '[% project %]-[% c("version") %]-[% c("var/osname") %]-[% c("var/build_id") %].tar.gz'
+
+build: '[% c("projects/go/var/build_go_lib") %]'
+
+var:
+ container:
+ use_container: 1
+ no_crosscompile: 1
+ go_lib: golang.org/x/image
+ go_lib_install:
+ - golang.org/x/image/webp
+ - golang.org/x/image/bmp
+ - golang.org/x/image/draw
+ - golang.org/x/image/font
+ - golang.org/x/image/math/fixed
+ - golang.org/x/image/math/f32
+ - golang.org/x/image/math/f64
+ - golang.org/x/image/vp8
+ - golang.org/x/image/vp8l
+
+input_files:
+ - project: container-image
+ - name: go
+ project: go
diff --git a/projects/goxnet/config b/projects/goxnet/config
index f6a2c29..5394875 100644
--- a/projects/goxnet/config
+++ b/projects/goxnet/config
@@ -16,9 +16,18 @@ var:
go_lib_deps:
- goxsys
+targets:
+ android:
+ var:
+ build_go_lib_pre: |
+ [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
+
input_files:
- project: container-image
- name: go
project: go
- name: goxsys
project: goxsys
+ - name: '[% c("var/compiler") %]'
+ project: '[% c("var/compiler") %]'
+ enable: '[% c("var/android") %]'
diff --git a/projects/obfs4/build b/projects/obfs4/build
index 33b0add..53b83df 100644
--- a/projects/obfs4/build
+++ b/projects/obfs4/build
@@ -5,6 +5,10 @@ distdir=/var/tmp/dist/[% project %]
[% c("var/set_PTDIR_DOCSDIR") -%]
mkdir -p $PTDIR
+[% IF c("var/android") -%]
+ [% pc(c('var/compiler'), 'var/setup', { compiler_tarfile => c('input_files_by_name/' _ c('var/compiler')) }) %]
+[% END -%]
+
tar -C /var/tmp/dist -xf [% c('input_files_by_name/goptlib') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/ed25519') %]
tar -C /var/tmp/dist -xf [% c('input_files_by_name/siphash') %]
diff --git a/projects/obfs4/config b/projects/obfs4/config
index d9357bb..21bdab6 100644
--- a/projects/obfs4/config
+++ b/projects/obfs4/config
@@ -36,3 +36,6 @@ input_files:
project: goutls
- name: goxtext
project: goxtext
+ - name: '[% c("var/compiler") %]'
+ project: '[% c("var/compiler") %]'
+ enable: '[% c("var/android") %]'
diff --git a/projects/tor-onion-proxy-library/build b/projects/tor-onion-proxy-library/build
index 0b949a3..0f2d976 100644
--- a/projects/tor-onion-proxy-library/build
+++ b/projects/tor-onion-proxy-library/build
@@ -22,6 +22,16 @@ cd /var/tmp/build/[% project %]-[% c('version') %]
patch -p1 < $rootdir/gradle.patch
patch -p1 < $rootdir/canceldormant.patch
+# Extract obfs4proxy from TorBrowser/Tor/PluggableTransports/obfs4proxy
+tar --strip-components=4 -xf $rootdir/[% c('input_files_by_name/obfs4') %]
+
+# Overwrite the obfs4proxy binary provided by Pluto
+for d in external/pluto/bin/*; do
+ cp obfs4proxy $d/
+done
+
+rm obfs4proxy
+
# Build Android Libraries and Apps
$GRADLE_HOME/gradle-4.10.2/bin/gradle --offline --no-daemon -P androidplugin=3.1.0 -Dmaven.repo.local=$gradle_repo assembleRelease -x lint
diff --git a/projects/tor-onion-proxy-library/config b/projects/tor-onion-proxy-library/config
index c2bd1a4..ff3432c 100644
--- a/projects/tor-onion-proxy-library/config
+++ b/projects/tor-onion-proxy-library/config
@@ -25,6 +25,8 @@ input_files:
- project: container-image
- name: '[% c("var/compiler") %]'
project: '[% c("var/compiler") %]'
+ - project: obfs4
+ name: obfs4
- filename: 'gradle-dependencies-[% c("var/gradle_dependencies_version") %]'
name: gradle-dependencies
exec: '[% INCLUDE "fetch-gradle-dependencies" %]'
diff --git a/rbm.conf b/rbm.conf
index 727c09f..aaa6e3a 100644
--- a/rbm.conf
+++ b/rbm.conf
@@ -183,6 +183,7 @@ targets:
var:
android-armv7: 1
osname: android-armv7
+ toolchain_arch: arm
torbrowser-android-x86:
- android-x86
- android
@@ -191,6 +192,7 @@ targets:
var:
android-x86: 1
osname: android-x86
+ toolchain_arch: x86
torbrowser-android-x86_64:
- android-x86_64
- android
@@ -199,6 +201,7 @@ targets:
var:
android-x86_64: 1
osname: android-x86_64
+ toolchain_arch: x86_64
torbrowser-android-aarch64:
- android-aarch64
- android
@@ -207,6 +210,7 @@ targets:
var:
android-aarch64: 1
osname: android-aarch64
+ toolchain_arch: arm64
android:
var:
android: 1
@@ -219,6 +223,8 @@ targets:
android_min_api_x86: 16
android_min_api_x86_64: 21
snowflake: 0
+ CC: '$ANDROID_NDK_HOME/[% c("var/toolchain_arch") %]/bin/clang'
+ CXX: '$ANDROID_NDK_HOME/[% c("var/toolchain_arch") %]/bin/clang++'
container:
suite: stretch
arch: amd64
1
0

07 Nov '19
commit 878a3855c2b7fc5146cd8c38d2b25a7ed427c7e9
Author: Matthew Finkel <sysrqb(a)torproject.org>
Date: Sat Oct 26 17:15:20 2019 +0000
Bug 32303: Fix broken obfs4 on Android Q
Backport go patch #29674 that drops the TLS section on Android.
---
.../90a3ce02dc25adcf1598faf11a66b151ada3f637.patch | 57 ++++++++++++++++++++++
projects/go/build | 2 +
projects/go/config | 2 +
3 files changed, 61 insertions(+)
diff --git a/projects/go/90a3ce02dc25adcf1598faf11a66b151ada3f637.patch b/projects/go/90a3ce02dc25adcf1598faf11a66b151ada3f637.patch
new file mode 100644
index 0000000..dc66809
--- /dev/null
+++ b/projects/go/90a3ce02dc25adcf1598faf11a66b151ada3f637.patch
@@ -0,0 +1,57 @@
+From 90a3ce02dc25adcf1598faf11a66b151ada3f637 Mon Sep 17 00:00:00 2001
+From: Elias Naur <mail(a)eliasnaur.com>
+Date: Wed, 27 Mar 2019 14:25:24 +0100
+Subject: [PATCH] cmd/link/internal/ld: skip TLS section on Android
+
+We don't use the TLS section on android, and dropping it avoids
+complaints about underalignment from the Android Q linker.
+
+Updates #29674
+
+Change-Id: I91dabf2a58e6eb1783872639a6a144858db09cef
+Reviewed-on: https://go-review.googlesource.com/c/go/+/169618
+Reviewed-by: Ian Lance Taylor <iant(a)golang.org>
+---
+ src/cmd/link/internal/ld/lib.go | 29 +++++++++++++++++------------
+ 1 file changed, 17 insertions(+), 12 deletions(-)
+
+diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
+index 1d44c0eb18b..b331e39fe3e 100644
+--- a/src/cmd/link/internal/ld/lib.go
++++ b/src/cmd/link/internal/ld/lib.go
+@@ -453,18 +453,23 @@ func (ctxt *Link) loadlib() {
+ }
+ }
+
+- tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
+-
+- // runtime.tlsg is used for external linking on platforms that do not define
+- // a variable to hold g in assembly (currently only intel).
+- if tlsg.Type == 0 {
+- tlsg.Type = sym.STLSBSS
+- tlsg.Size = int64(ctxt.Arch.PtrSize)
+- } else if tlsg.Type != sym.SDYNIMPORT {
+- Errorf(nil, "runtime declared tlsg variable %v", tlsg.Type)
+- }
+- tlsg.Attr |= sym.AttrReachable
+- ctxt.Tlsg = tlsg
++ // The Android Q linker started to complain about underalignment of the our TLS
++ // section. We don't actually use the section on android, so dont't
++ // generate it.
++ if objabi.GOOS != "android" {
++ tlsg := ctxt.Syms.Lookup("runtime.tlsg", 0)
++
++ // runtime.tlsg is used for external linking on platforms that do not define
++ // a variable to hold g in assembly (currently only intel).
++ if tlsg.Type == 0 {
++ tlsg.Type = sym.STLSBSS
++ tlsg.Size = int64(ctxt.Arch.PtrSize)
++ } else if tlsg.Type != sym.SDYNIMPORT {
++ Errorf(nil, "runtime declared tlsg variable %v", tlsg.Type)
++ }
++ tlsg.Attr |= sym.AttrReachable
++ ctxt.Tlsg = tlsg
++ }
+
+ var moduledata *sym.Symbol
+ if ctxt.BuildMode == BuildModePlugin {
diff --git a/projects/go/build b/projects/go/build
index aa092d6..2ebfd58 100644
--- a/projects/go/build
+++ b/projects/go/build
@@ -68,6 +68,8 @@ cd /var/tmp/dist/go/src
CGO_ENABLED=1 CC_FOR_TARGET="$CC_FOR_TARGET" CC= CFLAGS= LDFLAGS= ./make.bash
[% ELSIF c("var/android") -%]
patch -p2 < $rootdir/0001-Use-fixed-go-build-tmp-directory.patch
+ # Obfs4 breaks on Android Q without this patch, see: #32303
+ patch -p2 < $rootdir/90a3ce02dc25adcf1598faf11a66b151ada3f637.patch
CGO_ENABLED=1 CC_FOR_TARGET=[% c("var/CC") %] CGO_CFLAGS='-D__ANDROID_API__=[% c("var/android_min_api") %]' CC= CFLAGS= LDFLAGS= ./make.bash
[% END -%]
diff --git a/projects/go/config b/projects/go/config
index 31c510a..cf95b90 100644
--- a/projects/go/config
+++ b/projects/go/config
@@ -118,3 +118,5 @@ input_files:
sha256sum: 9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959
- filename: 0001-Use-fixed-go-build-tmp-directory.patch
enable: '[% c("var/android") %]'
+ - filename: 90a3ce02dc25adcf1598faf11a66b151ada3f637.patch
+ enable: '[% c("var/android") %]'
1
0
commit d71e357c70606afd1c3bbbc41161be833ed62c93
Author: Matthew Finkel <sysrqb(a)torproject.org>
Date: Wed Nov 6 21:06:52 2019 +0000
Bug 32413: Bump Go to 1.12.13
Pick up security fixes.
---
projects/go/config | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/projects/go/config b/projects/go/config
index cf95b90..371f8c2 100644
--- a/projects/go/config
+++ b/projects/go/config
@@ -1,5 +1,5 @@
# vim: filetype=yaml sw=2
-version: 1.12.9
+version: 1.12.13
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
var:
@@ -112,7 +112,7 @@ input_files:
enable: '[% ! c("var/linux") %]'
- URL: 'https://golang.org/dl/go[% c("version") %].src.tar.gz'
name: go
- sha256sum: ab0e56ed9c4732a653ed22e232652709afbf573e710f56a07f7fdeca578d62fc
+ sha256sum: 5383d3b8db4baa48284ffcb14606d9cad6f03e9db843fa6d835b94d63cccf5a7
- URL: 'https://golang.org/dl/go[% c("var/go14_version") %].src.tar.gz'
name: go14
sha256sum: 9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959
1
0

[tor-browser-build/master] Merge remote-tracking branch 'gk/bug_32303_fixup_squashed'
by gk@torproject.org 07 Nov '19
by gk@torproject.org 07 Nov '19
07 Nov '19
commit beb07216af27edf1eb3ee8788d3960a59d114d14
Merge: 1a0dcc9 d71e357
Author: Georg Koppen <gk(a)torproject.org>
Date: Thu Nov 7 10:11:39 2019 +0000
Merge remote-tracking branch 'gk/bug_32303_fixup_squashed'
.../go/0001-Use-fixed-go-build-tmp-directory.patch | 33 +++++++++++++
.../90a3ce02dc25adcf1598faf11a66b151ada3f637.patch | 57 ++++++++++++++++++++++
projects/go/build | 14 +++---
projects/go/config | 36 ++++++++++++--
projects/gobsaes/config | 9 ++++
...BILE_TMPDIR-env-variable-is-defined-use-t.patch | 35 +++++++++++++
projects/gomobile/config | 33 +++++++++++++
projects/goptlib/config | 8 +++
projects/goutls/config | 9 ++++
projects/goxexp/config | 19 ++++++++
projects/goximage/config | 28 +++++++++++
projects/goxnet/config | 9 ++++
projects/obfs4/build | 4 ++
projects/obfs4/config | 3 ++
projects/tor-onion-proxy-library/build | 10 ++++
projects/tor-onion-proxy-library/config | 2 +
rbm.conf | 6 +++
17 files changed, 304 insertions(+), 11 deletions(-)
1
0

07 Nov '19
commit 1a0dcc91b00f38122af69a20e3121760bc18fbf3
Author: Georg Koppen <gk(a)torproject.org>
Date: Thu Nov 7 10:09:24 2019 +0000
Bump NoScript version to 11.0.7
---
projects/tor-browser/config | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/projects/tor-browser/config b/projects/tor-browser/config
index f78b4f8..56c13bc 100644
--- a/projects/tor-browser/config
+++ b/projects/tor-browser/config
@@ -73,9 +73,9 @@ input_files:
enable: '[% c("var/snowflake") %]'
- filename: Bundle-Data
enable: '[% ! c("var/android") %]'
- - URL: https://addons.cdn.mozilla.net/user-media/addons/722/noscript_security_suit…
+ - URL: https://addons.cdn.mozilla.net/user-media/addons/722/noscript_security_suit…
name: noscript
- sha256sum: b068f8e1bd7d53e7a2d6959e5449621d0ae073c5f12271e027aad13a1e837961
+ sha256sum: bc7063510c201cdb32d4569ebed7cdac95e565dbe50dcae0a92a0233f80f747a
- filename: 'RelativeLink/start-tor-browser.desktop'
enable: '[% c("var/linux") %]'
- filename: 'RelativeLink/execdesktop'
1
0

[tor-browser/tor-browser-68.2.0esr-9.5-1] Bug 32220: Improve the letterboxing experience
by gk@torproject.org 06 Nov '19
by gk@torproject.org 06 Nov '19
06 Nov '19
commit ff8083901a19421e9a3f0dba5346bd6873fee956
Author: Richard Pospesel <richard(a)torproject.org>
Date: Mon Oct 28 17:42:17 2019 -0700
Bug 32220: Improve the letterboxing experience
CSS and JS changes to alter the UX surrounding letterboxing. The
browser element containing page content is now anchored to the bottom
of the toolbar, and the remaining letterbox margin is the same color
as the firefox chrome. The letterbox margin and border are tied to
the currently selected theme.
Also adds a 'needsLetterbox' property to tabbrowser.xml to fix a race
condition present when using the 'isEmpty' property. Using 'isEmpty'
as a proxy for 'needsLetterbox' resulted in over-zealous/unnecessary
letterboxing of about:blank tabs.
---
browser/base/content/browser.css | 7 ++
browser/base/content/tabbrowser.xml | 10 +++
browser/themes/shared/tabs.inc.css | 6 ++
.../components/resistfingerprinting/RFPHelper.jsm | 94 +++++++++++++++++++---
4 files changed, 105 insertions(+), 12 deletions(-)
diff --git a/browser/base/content/browser.css b/browser/base/content/browser.css
index 8137435f9ed6..c5ca3de4a67f 100644
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -70,6 +70,13 @@
min-width: 25px;
}
+.browserStack > browser.letterboxing {
+ border-color: var(--chrome-content-separator-color);
+ border-style: solid;
+ border-width : 1px;
+ border-top: none;
+}
+
%ifdef MENUBAR_CAN_AUTOHIDE
#toolbar-menubar[autohide="true"] {
overflow: hidden;
diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml
index 3430b8a1d69d..dc1baa71f6c4 100644
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -2090,6 +2090,16 @@
</getter>
</property>
+ <property name="needsLetterbox" readonly="true">
+ <getter>
+ let browser = this.linkedBrowser;
+ if (isBlankPageURL(browser.currentURI.spec))
+ return false;
+
+ return true;
+ </getter>
+ </property>
+
<property name="lastAccessed">
<getter>
return this._lastAccessed == Infinity ? Date.now() : this._lastAccessed;
diff --git a/browser/themes/shared/tabs.inc.css b/browser/themes/shared/tabs.inc.css
index 7fc107e8d997..1e05b592d6c8 100644
--- a/browser/themes/shared/tabs.inc.css
+++ b/browser/themes/shared/tabs.inc.css
@@ -33,6 +33,12 @@
background-color: #f9f9fa;
}
+/* extend down the toolbar's colors when letterboxing is enabled*/
+#tabbrowser-tabpanels.letterboxing {
+ background-color: var(--toolbar-bgcolor);
+ background-image: var(--toolbar-bgimage);
+}
+
:root[privatebrowsingmode=temporary] #tabbrowser-tabpanels {
/* Value for --in-content-page-background in aboutPrivateBrowsing.css */
background-color: #25003e;
diff --git a/toolkit/components/resistfingerprinting/RFPHelper.jsm b/toolkit/components/resistfingerprinting/RFPHelper.jsm
index f73ccf1797b0..6c9306dc7bb3 100644
--- a/toolkit/components/resistfingerprinting/RFPHelper.jsm
+++ b/toolkit/components/resistfingerprinting/RFPHelper.jsm
@@ -41,6 +41,7 @@ class _RFPHelper {
// ============================================================================
constructor() {
this._initialized = false;
+ this._borderDimensions = null;
}
init() {
@@ -348,6 +349,24 @@ class _RFPHelper {
});
}
+ getBorderDimensions(aBrowser) {
+ if (this._borderDimensions) {
+ return this._borderDimensions;
+ }
+
+ const win = aBrowser.ownerGlobal;
+ const browserStyle = win.getComputedStyle(aBrowser);
+
+ this._borderDimensions = {
+ top : parseInt(browserStyle.borderTopWidth),
+ right: parseInt(browserStyle.borderRightWidth),
+ bottom : parseInt(browserStyle.borderBottomWidth),
+ left : parseInt(browserStyle.borderLeftWidth),
+ };
+
+ return this._borderDimensions;
+ }
+
_addOrClearContentMargin(aBrowser) {
let tab = aBrowser.getTabBrowser().getTabForBrowser(aBrowser);
@@ -356,9 +375,13 @@ class _RFPHelper {
return;
}
+ // we add the letterboxing class even if the content does not need letterboxing
+ // in which case margins are set such that the borders are hidden
+ aBrowser.classList.add("letterboxing");
+
// We should apply no margin around an empty tab or a tab with system
// principal.
- if (tab.isEmpty || aBrowser.contentPrincipal.isSystemPrincipal) {
+ if (!tab.needsLetterbox || aBrowser.contentPrincipal.isSystemPrincipal) {
this._clearContentViewMargin(aBrowser);
} else {
this._roundContentView(aBrowser);
@@ -523,10 +546,29 @@ class _RFPHelper {
// Calculating the margins around the browser element in order to round the
// content viewport. We will use a 200x100 stepping if the dimension set
// is not given.
- let margins = calcMargins(containerWidth, containerHeight);
+
+ const borderDimensions = this.getBorderDimensions(aBrowser);
+ const marginDims = calcMargins(containerWidth, containerHeight - borderDimensions.top);
+
+ let margins = {
+ top : 0,
+ right : 0,
+ bottom : 0,
+ left : 0,
+ };
+
+ // snap browser element to top
+ margins.top = 0;
+ // and leave 'double' margin at the bottom
+ margins.bottom = 2 * marginDims.height - borderDimensions.bottom;
+ // identical margins left and right
+ margins.right = marginDims.width - borderDimensions.right;
+ margins.left = marginDims.width - borderDimensions.left;
+
+ const marginStyleString = `${margins.top}px ${margins.right}px ${margins.bottom}px ${margins.left}px`;
// If the size of the content is already quantized, we do nothing.
- if (aBrowser.style.margin == `${margins.height}px ${margins.width}px`) {
+ if (aBrowser.style.margin === marginStyleString) {
log("_roundContentView[" + logId + "] is_rounded == true");
if (this._isLetterboxingTesting) {
log(
@@ -547,19 +589,35 @@ class _RFPHelper {
"_roundContentView[" +
logId +
"] setting margins to " +
- margins.width +
- " x " +
- margins.height
+ marginStyleString
);
- // One cannot (easily) control the color of a margin unfortunately.
- // An initial attempt to use a border instead of a margin resulted
- // in offset event dispatching; so for now we use a colorless margin.
- aBrowser.style.margin = `${margins.height}px ${margins.width}px`;
+
+ // The margin background color is determined by the background color of the
+ // window's tabpanels#tabbrowser-tabpanels element
+ aBrowser.style.margin = marginStyleString;
});
}
_clearContentViewMargin(aBrowser) {
+ const borderDimensions = this.getBorderDimensions(aBrowser);
+ // set the margins such that the browser elements border is visible up top, but
+ // are rendered off-screen on the remaining sides
+ let margins = {
+ top : 0,
+ right : -borderDimensions.right,
+ bottom : -borderDimensions.bottom,
+ left : -borderDimensions.left,
+ };
+ const marginStyleString = `${margins.top}px ${margins.right}px ${margins.bottom}px ${margins.left}px`;
+
+ aBrowser.ownerGlobal.requestAnimationFrame(() => {
+ aBrowser.style.margin = marginStyleString;
+ });
+ }
+
+ _removeLetterboxing(aBrowser) {
aBrowser.ownerGlobal.requestAnimationFrame(() => {
+ aBrowser.classList.remove("letterboxing");
aBrowser.style.margin = "";
});
}
@@ -581,6 +639,11 @@ class _RFPHelper {
this
);
+ const tabPanel = aWindow.document.getElementById("tabbrowser-tabpanels");
+ if (tabPanel) {
+ tabPanel.classList.add("letterboxing");
+ }
+
// Rounding the content viewport.
this._updateMarginsForTabsInWindow(aWindow);
}
@@ -608,10 +671,17 @@ class _RFPHelper {
this
);
- // Clear all margins and tooltip for all browsers.
+ // revert tabpanel's background colors to default
+ const tabPanel = aWindow.document.getElementById("tabbrowser-tabpanels");
+ if (tabPanel) {
+ tabPanel.classList.remove("letterboxing");
+ }
+
+ // and revert each browser element to default,
+ // restore default margins and remove letterboxing class
for (let tab of tabBrowser.tabs) {
let browser = tab.linkedBrowser;
- this._clearContentViewMargin(browser);
+ this._removeLetterboxing(browser);
}
}
1
0

[tor-browser/tor-browser-68.2.0esr-9.5-1] Revert "Bug 30683: Prevent detection of locale via some *.properties"
by gk@torproject.org 06 Nov '19
by gk@torproject.org 06 Nov '19
06 Nov '19
commit cb255f2504b37916160e886a181f1a02f85dba7c
Author: Alex Catarineu <acat(a)torproject.org>
Date: Tue Nov 5 10:53:21 2019 +0100
Revert "Bug 30683: Prevent detection of locale via some *.properties"
This reverts commit ab53cf71411a60ca56d5f6e24ec118802b8788df.
---
browser/installer/package-manifest.in | 3 ---
dom/base/nsContentUtils.cpp | 17 ++++-------------
dom/base/nsContentUtils.h | 4 ----
dom/html/HTMLSelectElement.cpp | 2 +-
dom/html/HTMLTextAreaElement.cpp | 6 +++---
dom/html/MediaDocument.cpp | 4 +---
dom/html/MediaDocument.h | 3 ---
dom/html/input/CheckableInputTypes.cpp | 4 ++--
dom/html/input/DateTimeInputTypes.cpp | 6 +++---
dom/html/input/FileInputType.cpp | 2 +-
dom/html/input/InputType.cpp | 16 ++++++++--------
dom/html/input/NumericInputTypes.cpp | 8 ++++----
dom/html/input/SingleLineTextInputTypes.cpp | 6 +++---
dom/locales/moz.build | 6 ------
mobile/android/installer/package-manifest.in | 3 ---
parser/htmlparser/nsParserMsgUtils.cpp | 6 ------
parser/htmlparser/nsParserMsgUtils.h | 3 ---
17 files changed, 30 insertions(+), 69 deletions(-)
diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in
index 1825397678d1..1a2a24f9b5b9 100644
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -345,9 +345,6 @@
@RESPATH@/res/dtd/*
@RESPATH@/res/language.properties
@RESPATH@/res/locale/layout/HtmlForm.properties
-@RESPATH@/res/locale/layout/MediaDocument.properties
-@RESPATH@/res/locale/layout/xmlparser.properties
-@RESPATH@/res/locale/dom/dom.properties
#ifdef XP_MACOSX
@RESPATH@/res/MainMenu.nib/
#endif
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index cfae3ef224b3..9c60c1befe1e 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -3575,9 +3575,7 @@ static const char* gPropertiesFiles[nsContentUtils::PropertiesFile_COUNT] = {
"chrome://global/locale/security/security.properties",
"chrome://necko/locale/necko.properties",
"chrome://global/locale/layout/HtmlForm.properties",
- "resource://gre/res/locale/layout/HtmlForm.properties",
- "chrome://global/locale/dom/dom.properties",
- "resource://gre/res/locale/dom/dom.properties"};
+ "resource://gre/res/locale/layout/HtmlForm.properties"};
/* static */
nsresult nsContentUtils::EnsureStringBundle(PropertiesFile aFile) {
@@ -3626,8 +3624,7 @@ void nsContentUtils::AsyncPrecreateStringBundles() {
}
}
-/* static */
-bool nsContentUtils::SpoofLocaleEnglish() {
+static bool SpoofLocaleEnglish() {
// 0 - will prompt
// 1 - don't spoof
// 2 - spoof
@@ -3638,12 +3635,9 @@ bool nsContentUtils::SpoofLocaleEnglish() {
nsresult nsContentUtils::GetLocalizedString(PropertiesFile aFile,
const char* aKey,
nsAString& aResult) {
- // When we spoof English, use en-US properties in strings that are accessible
- // by content.
+ // When we spoof English, use en-US default strings in HTML forms.
if (aFile == eFORMS_PROPERTIES_MAYBESPOOF && SpoofLocaleEnglish()) {
aFile = eFORMS_PROPERTIES_en_US;
- } else if (aFile == eDOM_PROPERTIES_MAYBESPOOF && SpoofLocaleEnglish()) {
- aFile = eDOM_PROPERTIES_en_US;
}
nsresult rv = EnsureStringBundle(aFile);
@@ -3658,12 +3652,9 @@ nsresult nsContentUtils::FormatLocalizedString(PropertiesFile aFile,
const char16_t** aParams,
uint32_t aParamsLength,
nsAString& aResult) {
- // When we spoof English, use en-US properties in strings that are accessible
- // by content.
+ // When we spoof English, use en-US default strings in HTML forms.
if (aFile == eFORMS_PROPERTIES_MAYBESPOOF && SpoofLocaleEnglish()) {
aFile = eFORMS_PROPERTIES_en_US;
- } else if (aFile == eDOM_PROPERTIES_MAYBESPOOF && SpoofLocaleEnglish()) {
- aFile = eDOM_PROPERTIES_en_US;
}
nsresult rv = EnsureStringBundle(aFile);
diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
index 2bf27250e68b..ee23a540871d 100644
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -1119,8 +1119,6 @@ class nsContentUtils {
eNECKO_PROPERTIES,
eFORMS_PROPERTIES_MAYBESPOOF,
eFORMS_PROPERTIES_en_US,
- eDOM_PROPERTIES_MAYBESPOOF,
- eDOM_PROPERTIES_en_US,
PropertiesFile_COUNT
};
static nsresult ReportToConsole(
@@ -1134,8 +1132,6 @@ class nsContentUtils {
static void LogMessageToConsole(const char* aMsg);
- static bool SpoofLocaleEnglish();
-
/**
* Get the localized string named |aKey| in properties file |aFile|.
*/
diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp
index afa01ee224ba..76f21db23b31 100644
--- a/dom/html/HTMLSelectElement.cpp
+++ b/dom/html/HTMLSelectElement.cpp
@@ -1539,7 +1539,7 @@ nsresult HTMLSelectElement::GetValidationMessage(nsAString& aValidationMessage,
case VALIDITY_STATE_VALUE_MISSING: {
nsAutoString message;
nsresult rv = nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationSelectMissing",
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationSelectMissing",
message);
aValidationMessage = message;
return rv;
diff --git a/dom/html/HTMLTextAreaElement.cpp b/dom/html/HTMLTextAreaElement.cpp
index 2844267b9bb8..0d1ba35c8b59 100644
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -1001,7 +1001,7 @@ nsresult HTMLTextAreaElement::GetValidationMessage(
const char16_t* params[] = {strMaxLength.get(), strTextLength.get()};
rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationTextTooLong", params,
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooLong", params,
message);
aValidationMessage = message;
} break;
@@ -1017,13 +1017,13 @@ nsresult HTMLTextAreaElement::GetValidationMessage(
const char16_t* params[] = {strMinLength.get(), strTextLength.get()};
rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationTextTooShort", params,
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooShort", params,
message);
aValidationMessage = message;
} break;
case VALIDITY_STATE_VALUE_MISSING: {
nsAutoString message;
- rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF,
+ rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"FormValidationValueMissing",
message);
aValidationMessage = message;
diff --git a/dom/html/MediaDocument.cpp b/dom/html/MediaDocument.cpp
index 7ec66b31e63d..196adddc0f38 100644
--- a/dom/html/MediaDocument.cpp
+++ b/dom/html/MediaDocument.cpp
@@ -125,9 +125,7 @@ nsresult MediaDocument::Init() {
nsCOMPtr<nsIStringBundleService> stringService =
mozilla::services::GetStringBundleService();
if (stringService) {
- stringService->CreateBundle(nsContentUtils::SpoofLocaleEnglish()
- ? NSMEDIADOCUMENT_PROPERTIES_URI_en_US
- : NSMEDIADOCUMENT_PROPERTIES_URI,
+ stringService->CreateBundle(NSMEDIADOCUMENT_PROPERTIES_URI,
getter_AddRefs(mStringBundle));
}
diff --git a/dom/html/MediaDocument.h b/dom/html/MediaDocument.h
index 37e005c7fffa..e11fd2ec8551 100644
--- a/dom/html/MediaDocument.h
+++ b/dom/html/MediaDocument.h
@@ -16,9 +16,6 @@
#define NSMEDIADOCUMENT_PROPERTIES_URI \
"chrome://global/locale/layout/MediaDocument.properties"
-#define NSMEDIADOCUMENT_PROPERTIES_URI_en_US \
- "resource://gre/res/locale/layout/MediaDocument.properties"
-
namespace mozilla {
namespace dom {
diff --git a/dom/html/input/CheckableInputTypes.cpp b/dom/html/input/CheckableInputTypes.cpp
index f0306b69cbd0..f55000c766ea 100644
--- a/dom/html/input/CheckableInputTypes.cpp
+++ b/dom/html/input/CheckableInputTypes.cpp
@@ -23,7 +23,7 @@ bool CheckboxInputType::IsValueMissing() const {
}
nsresult CheckboxInputType::GetValueMissingMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF,
+ return nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"FormValidationCheckboxMissing",
aMessage);
}
@@ -32,5 +32,5 @@ nsresult CheckboxInputType::GetValueMissingMessage(nsAString& aMessage) {
nsresult RadioInputType::GetValueMissingMessage(nsAString& aMessage) {
return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationRadioMissing", aMessage);
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationRadioMissing", aMessage);
}
diff --git a/dom/html/input/DateTimeInputTypes.cpp b/dom/html/input/DateTimeInputTypes.cpp
index 0efbe9a9121a..11dfc9e541b9 100644
--- a/dom/html/input/DateTimeInputTypes.cpp
+++ b/dom/html/input/DateTimeInputTypes.cpp
@@ -138,7 +138,7 @@ nsresult DateTimeInputTypeBase::GetRangeOverflowMessage(nsAString& aMessage) {
const char16_t* params[] = {maxStr.get()};
return nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationDateTimeRangeOverflow",
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationDateTimeRangeOverflow",
params, aMessage);
}
@@ -148,7 +148,7 @@ nsresult DateTimeInputTypeBase::GetRangeUnderflowMessage(nsAString& aMessage) {
const char16_t* params[] = {minStr.get()};
return nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationDateTimeRangeUnderflow",
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationDateTimeRangeUnderflow",
params, aMessage);
}
@@ -194,7 +194,7 @@ nsresult DateInputType::GetBadInputMessage(nsAString& aMessage) {
}
return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationInvalidDate", aMessage);
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidDate", aMessage);
}
bool DateInputType::ConvertStringToNumber(
diff --git a/dom/html/input/FileInputType.cpp b/dom/html/input/FileInputType.cpp
index 82a4c2de8659..2536a875b2ca 100644
--- a/dom/html/input/FileInputType.cpp
+++ b/dom/html/input/FileInputType.cpp
@@ -22,5 +22,5 @@ bool FileInputType::IsValueMissing() const {
nsresult FileInputType::GetValueMissingMessage(nsAString& aMessage) {
return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationFileMissing", aMessage);
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationFileMissing", aMessage);
}
diff --git a/dom/html/input/InputType.cpp b/dom/html/input/InputType.cpp
index f7a28f4c1a3a..210daeafad14 100644
--- a/dom/html/input/InputType.cpp
+++ b/dom/html/input/InputType.cpp
@@ -167,7 +167,7 @@ nsresult InputType::GetValidationMessage(
const char16_t* params[] = {strMaxLength.get(), strTextLength.get()};
rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationTextTooLong", params,
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooLong", params,
message);
aValidationMessage = message;
break;
@@ -185,7 +185,7 @@ nsresult InputType::GetValidationMessage(
const char16_t* params[] = {strMinLength.get(), strTextLength.get()};
rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationTextTooShort", params,
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooShort", params,
message);
aValidationMessage = message;
@@ -216,7 +216,7 @@ nsresult InputType::GetValidationMessage(
nsAutoString title;
mInputElement->GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
if (title.IsEmpty()) {
- rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF,
+ rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"FormValidationPatternMismatch",
message);
} else {
@@ -227,7 +227,7 @@ nsresult InputType::GetValidationMessage(
}
const char16_t* params[] = {title.get()};
rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF,
+ nsContentUtils::eDOM_PROPERTIES,
"FormValidationPatternMismatchWithTitle", params, message);
}
aValidationMessage = message;
@@ -279,12 +279,12 @@ nsresult InputType::GetValidationMessage(
if (valueLowStr.Equals(valueHighStr)) {
const char16_t* params[] = {valueLowStr.get()};
rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF,
+ nsContentUtils::eDOM_PROPERTIES,
"FormValidationStepMismatchOneValue", params, message);
} else {
const char16_t* params[] = {valueLowStr.get(), valueHighStr.get()};
rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationStepMismatch",
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationStepMismatch",
params, message);
}
} else {
@@ -293,7 +293,7 @@ nsresult InputType::GetValidationMessage(
const char16_t* params[] = {valueLowStr.get()};
rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF,
+ nsContentUtils::eDOM_PROPERTIES,
"FormValidationStepMismatchOneValue", params, message);
}
@@ -319,7 +319,7 @@ nsresult InputType::GetValidationMessage(
nsresult InputType::GetValueMissingMessage(nsAString& aMessage) {
return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationValueMissing", aMessage);
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationValueMissing", aMessage);
}
nsresult InputType::GetTypeMismatchMessage(nsAString& aMessage) {
diff --git a/dom/html/input/NumericInputTypes.cpp b/dom/html/input/NumericInputTypes.cpp
index ab0f6f36eb95..6332e028c17e 100644
--- a/dom/html/input/NumericInputTypes.cpp
+++ b/dom/html/input/NumericInputTypes.cpp
@@ -73,7 +73,7 @@ nsresult NumericInputTypeBase::GetRangeOverflowMessage(nsAString& aMessage) {
const char16_t* params[] = {maxStr.get()};
return nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationNumberRangeOverflow",
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationNumberRangeOverflow",
params, aMessage);
}
@@ -90,7 +90,7 @@ nsresult NumericInputTypeBase::GetRangeUnderflowMessage(nsAString& aMessage) {
const char16_t* params[] = {minStr.get()};
return nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationNumberRangeUnderflow",
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationNumberRangeUnderflow",
params, aMessage);
}
@@ -150,13 +150,13 @@ bool NumberInputType::HasBadInput() const {
}
nsresult NumberInputType::GetValueMissingMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF,
+ return nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"FormValidationBadInputNumber",
aMessage);
}
nsresult NumberInputType::GetBadInputMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF,
+ return nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
"FormValidationBadInputNumber",
aMessage);
}
diff --git a/dom/html/input/SingleLineTextInputTypes.cpp b/dom/html/input/SingleLineTextInputTypes.cpp
index c879276c86da..15cbe65a1941 100644
--- a/dom/html/input/SingleLineTextInputTypes.cpp
+++ b/dom/html/input/SingleLineTextInputTypes.cpp
@@ -117,7 +117,7 @@ bool URLInputType::HasTypeMismatch() const {
nsresult URLInputType::GetTypeMismatchMessage(nsAString& aMessage) {
return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationInvalidURL", aMessage);
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidURL", aMessage);
}
/* input type=email */
@@ -155,12 +155,12 @@ bool EmailInputType::HasBadInput() const {
nsresult EmailInputType::GetTypeMismatchMessage(nsAString& aMessage) {
return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationInvalidEmail", aMessage);
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidEmail", aMessage);
}
nsresult EmailInputType::GetBadInputMessage(nsAString& aMessage) {
return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES_MAYBESPOOF, "FormValidationInvalidEmail", aMessage);
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidEmail", aMessage);
}
/* static */
diff --git a/dom/locales/moz.build b/dom/locales/moz.build
index 51f4b88ccd47..b2bcd271de7c 100644
--- a/dom/locales/moz.build
+++ b/dom/locales/moz.build
@@ -62,10 +62,4 @@ JAR_MANIFESTS += ['jar.mn']
RESOURCE_FILES.locale.layout += [
'en-US/chrome/layout/HtmlForm.properties',
- 'en-US/chrome/layout/MediaDocument.properties',
- 'en-US/chrome/layout/xmlparser.properties',
-]
-
-RESOURCE_FILES.locale.dom += [
- 'en-US/chrome/dom/dom.properties',
]
diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in
index 33e0175a624e..2002a894fc51 100644
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -203,9 +203,6 @@
@BINPATH@/res/dtd/*
@BINPATH@/res/language.properties
@BINPATH@/res/locale/layout/HtmlForm.properties
-@BINPATH@/res/locale/layout/MediaDocument.properties
-@BINPATH@/res/locale/layout/xmlparser.properties
-@BINPATH@/res/locale/dom/dom.properties
#ifndef MOZ_ANDROID_EXCLUDE_FONTS
@BINPATH@/res/fonts/*
diff --git a/parser/htmlparser/nsParserMsgUtils.cpp b/parser/htmlparser/nsParserMsgUtils.cpp
index 47749732839e..3e369893d4f7 100644
--- a/parser/htmlparser/nsParserMsgUtils.cpp
+++ b/parser/htmlparser/nsParserMsgUtils.cpp
@@ -9,7 +9,6 @@
#include "nsParserMsgUtils.h"
#include "nsNetCID.h"
#include "mozilla/Services.h"
-#include "nsContentUtils.h"
static nsresult GetBundle(const char* aPropFileName,
nsIStringBundle** aBundle) {
@@ -22,11 +21,6 @@ static nsresult GetBundle(const char* aPropFileName,
mozilla::services::GetStringBundleService();
if (!stringService) return NS_ERROR_FAILURE;
- if (nsContentUtils::SpoofLocaleEnglish() &&
- strcmp(aPropFileName, XMLPARSER_PROPERTIES) == 0) {
- aPropFileName = XMLPARSER_PROPERTIES_en_US;
- }
-
return stringService->CreateBundle(aPropFileName, aBundle);
}
diff --git a/parser/htmlparser/nsParserMsgUtils.h b/parser/htmlparser/nsParserMsgUtils.h
index 3645610385c1..b4ec4784d65f 100644
--- a/parser/htmlparser/nsParserMsgUtils.h
+++ b/parser/htmlparser/nsParserMsgUtils.h
@@ -11,9 +11,6 @@
#define XMLPARSER_PROPERTIES \
"chrome://global/locale/layout/xmlparser.properties"
-#define XMLPARSER_PROPERTIES_en_US \
- "resource://gre/res/locale/layout/xmlparser.properties"
-
class nsParserMsgUtils {
nsParserMsgUtils(); // Currently this is not meant to be created, use the
// static methods
1
0

[tor-browser/tor-browser-68.2.0esr-9.5-1] Bug 1581537 - Avoid several browser language leaks r=smaug
by gk@torproject.org 06 Nov '19
by gk@torproject.org 06 Nov '19
06 Nov '19
commit 79d87f543224b0e9d69a7520e25d9179d4f2c2bc
Author: Alex Catarineu <acat(a)torproject.org>
Date: Mon Nov 4 16:56:27 2019 +0000
Bug 1581537 - Avoid several browser language leaks r=smaug
Spoof dom/dom.properties, layout/xmlparser.properties,
layout/MediaDocument.properties to en-US if needed.
Differential Revision: https://phabricator.services.mozilla.com/D46034
--HG--
extra : moz-landing-system : lando
---
.../browser_misused_characters_in_strings.js | 6 +++
browser/installer/package-manifest.in | 3 ++
dom/base/Document.cpp | 8 ++-
dom/base/Document.h | 5 ++
dom/base/nsContentUtils.cpp | 55 +++++++++++++++-----
dom/base/nsContentUtils.h | 32 +++++++++++-
dom/html/HTMLInputElement.cpp | 40 ++++++++-------
dom/html/HTMLSelectElement.cpp | 4 +-
dom/html/HTMLTextAreaElement.cpp | 18 +++----
dom/html/ImageDocument.cpp | 7 ++-
dom/html/MediaDocument.cpp | 59 ++++++++++++++--------
dom/html/MediaDocument.h | 7 +++
dom/html/input/CheckableInputTypes.cpp | 11 ++--
dom/html/input/DateTimeInputTypes.cpp | 13 ++---
dom/html/input/FileInputType.cpp | 5 +-
dom/html/input/InputType.cpp | 42 ++++++++-------
dom/html/input/NumericInputTypes.cpp | 20 ++++----
dom/html/input/SingleLineTextInputTypes.cpp | 15 +++---
dom/locales/moz.build | 6 +++
layout/base/nsCSSFrameConstructor.cpp | 9 ++--
layout/forms/nsFileControlFrame.cpp | 4 +-
layout/forms/nsGfxButtonControlFrame.cpp | 4 +-
layout/generic/DetailsFrame.cpp | 6 +--
mobile/android/installer/package-manifest.in | 3 ++
parser/htmlparser/nsExpatDriver.cpp | 23 ++++++---
parser/htmlparser/nsParserMsgUtils.h | 3 ++
26 files changed, 272 insertions(+), 136 deletions(-)
diff --git a/browser/base/content/test/static/browser_misused_characters_in_strings.js b/browser/base/content/test/static/browser_misused_characters_in_strings.js
index 4b1d9a75d3bb..a9667b4feb96 100644
--- a/browser/base/content/test/static/browser_misused_characters_in_strings.js
+++ b/browser/base/content/test/static/browser_misused_characters_in_strings.js
@@ -99,6 +99,12 @@ let gWhitelist = [
key: "PatternAttributeCompileFailure",
type: "single-quote",
},
+ // dom.properties is packaged twice so we need to have two exceptions for this string.
+ {
+ file: "dom.properties",
+ key: "PatternAttributeCompileFailure",
+ type: "single-quote",
+ },
{
file: "netError.dtd",
key: "inadequateSecurityError.longDesc",
diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in
index 1a2a24f9b5b9..1825397678d1 100644
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -345,6 +345,9 @@
@RESPATH@/res/dtd/*
@RESPATH@/res/language.properties
@RESPATH@/res/locale/layout/HtmlForm.properties
+@RESPATH@/res/locale/layout/MediaDocument.properties
+@RESPATH@/res/locale/layout/xmlparser.properties
+@RESPATH@/res/locale/dom/dom.properties
#ifdef XP_MACOSX
@RESPATH@/res/MainMenu.nib/
#endif
diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp
index cdeabc4dc7b9..df9e7bd78e72 100644
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -3231,7 +3231,7 @@ bool Document::DocumentSupportsL10n(JSContext* aCx, JSObject* aObject) {
}
void Document::LocalizationLinkAdded(Element* aLinkElement) {
- if (!nsContentUtils::PrincipalAllowsL10n(NodePrincipal(), GetDocumentURI())) {
+ if (!AllowsL10n()) {
return;
}
@@ -3262,7 +3262,7 @@ void Document::LocalizationLinkAdded(Element* aLinkElement) {
}
void Document::LocalizationLinkRemoved(Element* aLinkElement) {
- if (!nsContentUtils::PrincipalAllowsL10n(NodePrincipal(), GetDocumentURI())) {
+ if (!AllowsL10n()) {
return;
}
@@ -3314,6 +3314,10 @@ void Document::InitialDocumentTranslationCompleted() {
mPendingInitialTranslation = false;
}
+bool Document::AllowsL10n() const {
+ return nsContentUtils::PrincipalAllowsL10n(NodePrincipal(), GetDocumentURI());
+}
+
bool Document::IsWebAnimationsEnabled(JSContext* aCx, JSObject* /*unused*/) {
MOZ_ASSERT(NS_IsMainThread());
diff --git a/dom/base/Document.h b/dom/base/Document.h
index e65bb95d94c9..9c338b0bb153 100644
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -3661,6 +3661,11 @@ class Document : public nsINode,
*/
virtual void InitialDocumentTranslationCompleted();
+ /**
+ * Returns whether the document allows localization.
+ */
+ bool AllowsL10n() const;
+
protected:
RefPtr<DocumentL10n> mDocumentL10n;
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index 9c60c1befe1e..e75fd6c9af8b 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -3574,8 +3574,8 @@ static const char* gPropertiesFiles[nsContentUtils::PropertiesFile_COUNT] = {
"chrome://global/locale/mathml/mathml.properties",
"chrome://global/locale/security/security.properties",
"chrome://necko/locale/necko.properties",
- "chrome://global/locale/layout/HtmlForm.properties",
- "resource://gre/res/locale/layout/HtmlForm.properties"};
+ "resource://gre/res/locale/layout/HtmlForm.properties",
+ "resource://gre/res/locale/dom/dom.properties"};
/* static */
nsresult nsContentUtils::EnsureStringBundle(PropertiesFile aFile) {
@@ -3624,22 +3624,47 @@ void nsContentUtils::AsyncPrecreateStringBundles() {
}
}
-static bool SpoofLocaleEnglish() {
+/* static */
+bool nsContentUtils::SpoofLocaleEnglish() {
// 0 - will prompt
// 1 - don't spoof
// 2 - spoof
return StaticPrefs::privacy_spoof_english() == 2;
}
+static nsContentUtils::PropertiesFile GetMaybeSpoofedPropertiesFile(
+ nsContentUtils::PropertiesFile aFile, const char* aKey,
+ Document* aDocument) {
+ // When we spoof English, use en-US properties in strings that are accessible
+ // by content.
+ bool spoofLocale = nsContentUtils::SpoofLocaleEnglish() &&
+ (!aDocument || !aDocument->AllowsL10n());
+ if (spoofLocale) {
+ switch (aFile) {
+ case nsContentUtils::eFORMS_PROPERTIES:
+ return nsContentUtils::eFORMS_PROPERTIES_en_US;
+ case nsContentUtils::eDOM_PROPERTIES:
+ return nsContentUtils::eDOM_PROPERTIES_en_US;
+ default:
+ break;
+ }
+ }
+ return aFile;
+}
+
+/* static */
+nsresult nsContentUtils::GetMaybeLocalizedString(PropertiesFile aFile,
+ const char* aKey,
+ Document* aDocument,
+ nsAString& aResult) {
+ return GetLocalizedString(
+ GetMaybeSpoofedPropertiesFile(aFile, aKey, aDocument), aKey, aResult);
+}
+
/* static */
nsresult nsContentUtils::GetLocalizedString(PropertiesFile aFile,
const char* aKey,
nsAString& aResult) {
- // When we spoof English, use en-US default strings in HTML forms.
- if (aFile == eFORMS_PROPERTIES_MAYBESPOOF && SpoofLocaleEnglish()) {
- aFile = eFORMS_PROPERTIES_en_US;
- }
-
nsresult rv = EnsureStringBundle(aFile);
NS_ENSURE_SUCCESS(rv, rv);
nsIStringBundle* bundle = sStringBundles[aFile];
@@ -3647,16 +3672,20 @@ nsresult nsContentUtils::GetLocalizedString(PropertiesFile aFile,
}
/* static */
+nsresult nsContentUtils::FormatMaybeLocalizedString(
+ PropertiesFile aFile, const char* aKey, Document* aDocument,
+ const char16_t** aParams, uint32_t aParamsLength, nsAString& aResult) {
+ return FormatLocalizedString(
+ GetMaybeSpoofedPropertiesFile(aFile, aKey, aDocument), aKey, aParams,
+ aParamsLength, aResult);
+}
+
+/* static */
nsresult nsContentUtils::FormatLocalizedString(PropertiesFile aFile,
const char* aKey,
const char16_t** aParams,
uint32_t aParamsLength,
nsAString& aResult) {
- // When we spoof English, use en-US default strings in HTML forms.
- if (aFile == eFORMS_PROPERTIES_MAYBESPOOF && SpoofLocaleEnglish()) {
- aFile = eFORMS_PROPERTIES_en_US;
- }
-
nsresult rv = EnsureStringBundle(aFile);
NS_ENSURE_SUCCESS(rv, rv);
nsIStringBundle* bundle = sStringBundles[aFile];
diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
index ee23a540871d..5b1eefef3854 100644
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -1117,8 +1117,8 @@ class nsContentUtils {
eMATHML_PROPERTIES,
eSECURITY_PROPERTIES,
eNECKO_PROPERTIES,
- eFORMS_PROPERTIES_MAYBESPOOF,
eFORMS_PROPERTIES_en_US,
+ eDOM_PROPERTIES_en_US,
PropertiesFile_COUNT
};
static nsresult ReportToConsole(
@@ -1132,6 +1132,8 @@ class nsContentUtils {
static void LogMessageToConsole(const char* aMsg);
+ static bool SpoofLocaleEnglish();
+
/**
* Get the localized string named |aKey| in properties file |aFile|.
*/
@@ -1139,6 +1141,15 @@ class nsContentUtils {
nsAString& aResult);
/**
+ * Same as GetLocalizedString, except that it might use en-US locale depending
+ * on SpoofLocaleEnglish() and whether the document is a built-in browser
+ * page.
+ */
+ static nsresult GetMaybeLocalizedString(PropertiesFile aFile,
+ const char* aKey, Document* aDocument,
+ nsAString& aResult);
+
+ /**
* A helper function that parses a sandbox attribute (of an <iframe> or a CSP
* directive) and converts it to the set of flags used internally.
*
@@ -1210,6 +1221,15 @@ class nsContentUtils {
uint32_t aParamsLength,
nsAString& aResult);
+ /**
+ * Same as FormatLocalizedString, except that it might use en-US locale
+ * depending on SpoofLocaleEnglish() and whether the document is a built-in
+ * browser page.
+ */
+ static nsresult FormatMaybeLocalizedString(
+ PropertiesFile aFile, const char* aKey, Document* aDocument,
+ const char16_t** aParams, uint32_t aParamsLength, nsAString& aResult);
+
public:
template <uint32_t N>
static nsresult FormatLocalizedString(PropertiesFile aFile, const char* aKey,
@@ -1218,6 +1238,16 @@ class nsContentUtils {
return FormatLocalizedString(aFile, aKey, aParams, N, aResult);
}
+ template <uint32_t N>
+ static nsresult FormatMaybeLocalizedString(PropertiesFile aFile,
+ const char* aKey,
+ Document* aDocument,
+ const char16_t* (&aParams)[N],
+ nsAString& aResult) {
+ return FormatMaybeLocalizedString(aFile, aKey, aDocument, aParams, N,
+ aResult);
+ }
+
/**
* Fill (with the parameters given) the localized string named |aKey| in
* properties file |aFile| consuming an nsTArray of nsString parameters rather
diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp
index dd0365a7646c..3217c78a2757 100644
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -725,15 +725,16 @@ nsresult HTMLInputElement::InitFilePicker(FilePickerType aType) {
nsAutoString title;
nsAutoString okButtonLabel;
if (aType == FILE_PICKER_DIRECTORY) {
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "DirectoryUpload", title);
+ nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ "DirectoryUpload", OwnerDoc(),
+ title);
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF,
- "DirectoryPickerOkButtonLabel", okButtonLabel);
+ nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ "DirectoryPickerOkButtonLabel",
+ OwnerDoc(), okButtonLabel);
} else {
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "FileUpload", title);
+ nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ "FileUpload", OwnerDoc(), title);
}
nsCOMPtr<nsIFilePicker> filePicker =
@@ -2339,24 +2340,25 @@ void HTMLInputElement::GetDisplayFileName(nsAString& aValue) const {
if ((IsDirPickerEnabled() && Allowdirs()) ||
(StaticPrefs::dom_webkitBlink_dirPicker_enabled() &&
HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) {
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "NoDirSelected", value);
+ nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ "NoDirSelected", OwnerDoc(),
+ value);
} else if (HasAttr(kNameSpaceID_None, nsGkAtoms::multiple)) {
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "NoFilesSelected",
- value);
+ nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ "NoFilesSelected", OwnerDoc(),
+ value);
} else {
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "NoFileSelected",
- value);
+ nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ "NoFileSelected", OwnerDoc(),
+ value);
}
} else {
nsString count;
count.AppendInt(int(mFileData->mFilesOrDirectories.Length()));
const char16_t* params[] = {count.get()};
- nsContentUtils::FormatLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "XFilesSelected", params,
+ nsContentUtils::FormatMaybeLocalizedString(
+ nsContentUtils::eFORMS_PROPERTIES, "XFilesSelected", OwnerDoc(), params,
value);
}
@@ -5828,8 +5830,8 @@ HTMLInputElement::SubmitNamesValues(HTMLFormSubmission* aFormSubmission) {
!HasAttr(kNameSpaceID_None, nsGkAtoms::value)) {
// Get our default value, which is the same as our default label
nsAutoString defaultValue;
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "Submit", defaultValue);
+ nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ "Submit", OwnerDoc(), defaultValue);
value = defaultValue;
}
diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp
index 76f21db23b31..a7a93468af02 100644
--- a/dom/html/HTMLSelectElement.cpp
+++ b/dom/html/HTMLSelectElement.cpp
@@ -1538,9 +1538,9 @@ nsresult HTMLSelectElement::GetValidationMessage(nsAString& aValidationMessage,
switch (aType) {
case VALIDITY_STATE_VALUE_MISSING: {
nsAutoString message;
- nsresult rv = nsContentUtils::GetLocalizedString(
+ nsresult rv = nsContentUtils::GetMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES, "FormValidationSelectMissing",
- message);
+ OwnerDoc(), message);
aValidationMessage = message;
return rv;
}
diff --git a/dom/html/HTMLTextAreaElement.cpp b/dom/html/HTMLTextAreaElement.cpp
index 0d1ba35c8b59..5a5a81545142 100644
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -1000,9 +1000,9 @@ nsresult HTMLTextAreaElement::GetValidationMessage(
strTextLength.AppendInt(textLength);
const char16_t* params[] = {strMaxLength.get(), strTextLength.get()};
- rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooLong", params,
- message);
+ rv = nsContentUtils::FormatMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooLong",
+ OwnerDoc(), params, message);
aValidationMessage = message;
} break;
case VALIDITY_STATE_TOO_SHORT: {
@@ -1016,16 +1016,16 @@ nsresult HTMLTextAreaElement::GetValidationMessage(
strTextLength.AppendInt(textLength);
const char16_t* params[] = {strMinLength.get(), strTextLength.get()};
- rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooShort", params,
- message);
+ rv = nsContentUtils::FormatMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooShort",
+ OwnerDoc(), params, message);
aValidationMessage = message;
} break;
case VALIDITY_STATE_VALUE_MISSING: {
nsAutoString message;
- rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
- "FormValidationValueMissing",
- message);
+ rv = nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationValueMissing",
+ OwnerDoc(), message);
aValidationMessage = message;
} break;
default:
diff --git a/dom/html/ImageDocument.cpp b/dom/html/ImageDocument.cpp
index 87b70961a386..2de785f5fb51 100644
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -577,14 +577,13 @@ nsresult ImageDocument::OnLoadComplete(imgIRequest* aRequest,
UpdateTitleAndCharset();
// mImageContent can be null if the document is already destroyed
- if (NS_FAILED(aStatus) && mStringBundle && mImageContent) {
+ if (NS_FAILED(aStatus) && mImageContent) {
nsAutoCString src;
mDocumentURI->GetSpec(src);
NS_ConvertUTF8toUTF16 srcString(src);
const char16_t* formatString[] = {srcString.get()};
nsAutoString errorMsg;
- mStringBundle->FormatStringFromName("InvalidImage", formatString, 1,
- errorMsg);
+ FormatStringFromName("InvalidImage", formatString, 1, errorMsg);
mImageContent->SetAttr(kNameSpaceID_None, nsGkAtoms::alt, errorMsg, false);
}
@@ -788,7 +787,7 @@ void ImageDocument::UpdateTitleAndCharset() {
ratioStr.AppendInt(NSToCoordFloor(GetRatio() * 100));
const char16_t* formatString[1] = {ratioStr.get()};
- mStringBundle->FormatStringFromName("ScaledImage", formatString, 1, status);
+ FormatStringFromName("ScaledImage", formatString, 1, status);
}
static const char* const formatNames[4] = {
diff --git a/dom/html/MediaDocument.cpp b/dom/html/MediaDocument.cpp
index 196adddc0f38..48d209d67b11 100644
--- a/dom/html/MediaDocument.cpp
+++ b/dom/html/MediaDocument.cpp
@@ -121,14 +121,6 @@ nsresult MediaDocument::Init() {
nsresult rv = nsHTMLDocument::Init();
NS_ENSURE_SUCCESS(rv, rv);
- // Create a bundle for the localization
- nsCOMPtr<nsIStringBundleService> stringService =
- mozilla::services::GetStringBundleService();
- if (stringService) {
- stringService->CreateBundle(NSMEDIADOCUMENT_PROPERTIES_URI,
- getter_AddRefs(mStringBundle));
- }
-
mIsSyntheticDocument = true;
return NS_OK;
@@ -327,6 +319,38 @@ nsresult MediaDocument::LinkScript(const nsAString& aScript) {
return head->AppendChildTo(script, false);
}
+void MediaDocument::FormatStringFromName(const char* aName,
+ const char16_t** aParams,
+ uint32_t aLength, nsAString& aResult) {
+ bool spoofLocale = nsContentUtils::SpoofLocaleEnglish() && !AllowsL10n();
+ if (!spoofLocale) {
+ if (!mStringBundle) {
+ nsCOMPtr<nsIStringBundleService> stringService =
+ mozilla::services::GetStringBundleService();
+ if (stringService) {
+ stringService->CreateBundle(NSMEDIADOCUMENT_PROPERTIES_URI,
+ getter_AddRefs(mStringBundle));
+ }
+ }
+ if (mStringBundle) {
+ mStringBundle->FormatStringFromName(aName, aParams, aLength, aResult);
+ }
+ } else {
+ if (!mStringBundleEnglish) {
+ nsCOMPtr<nsIStringBundleService> stringService =
+ mozilla::services::GetStringBundleService();
+ if (stringService) {
+ stringService->CreateBundle(NSMEDIADOCUMENT_PROPERTIES_URI_en_US,
+ getter_AddRefs(mStringBundleEnglish));
+ }
+ }
+ if (mStringBundleEnglish) {
+ mStringBundleEnglish->FormatStringFromName(aName, aParams, aLength,
+ aResult);
+ }
+ }
+}
+
void MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
nsIChannel* aChannel,
const char* const* aFormatNames,
@@ -338,7 +362,6 @@ void MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
NS_ConvertASCIItoUTF16 typeStr(aTypeStr);
nsAutoString title;
- if (mStringBundle) {
// if we got a valid size (not all media have a size)
if (aWidth != 0 && aHeight != 0) {
nsAutoString widthStr;
@@ -349,27 +372,24 @@ void MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
if (!fileStr.IsEmpty()) {
const char16_t* formatStrings[4] = {fileStr.get(), typeStr.get(),
widthStr.get(), heightStr.get()};
- mStringBundle->FormatStringFromName(aFormatNames[eWithDimAndFile],
- formatStrings, 4, title);
+ FormatStringFromName(aFormatNames[eWithDimAndFile], formatStrings, 4,
+ title);
} else {
const char16_t* formatStrings[3] = {typeStr.get(), widthStr.get(),
heightStr.get()};
- mStringBundle->FormatStringFromName(aFormatNames[eWithDim],
- formatStrings, 3, title);
+ FormatStringFromName(aFormatNames[eWithDim], formatStrings, 3, title);
}
} else {
// If we got a filename, display it
if (!fileStr.IsEmpty()) {
const char16_t* formatStrings[2] = {fileStr.get(), typeStr.get()};
- mStringBundle->FormatStringFromName(aFormatNames[eWithFile],
- formatStrings, 2, title);
+ FormatStringFromName(aFormatNames[eWithFile], formatStrings, 2, title);
} else {
const char16_t* formatStrings[1] = {typeStr.get()};
- mStringBundle->FormatStringFromName(aFormatNames[eWithNoInfo],
- formatStrings, 1, title);
+ FormatStringFromName(aFormatNames[eWithNoInfo], formatStrings, 1,
+ title);
}
}
- }
// set it on the document
if (aStatus.IsEmpty()) {
@@ -379,8 +399,7 @@ void MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
nsAutoString titleWithStatus;
const nsPromiseFlatString& status = PromiseFlatString(aStatus);
const char16_t* formatStrings[2] = {title.get(), status.get()};
- mStringBundle->FormatStringFromName("TitleWithStatus", formatStrings, 2,
- titleWithStatus);
+ FormatStringFromName("TitleWithStatus", formatStrings, 2, titleWithStatus);
IgnoredErrorResult ignored;
SetTitle(titleWithStatus, ignored);
}
diff --git a/dom/html/MediaDocument.h b/dom/html/MediaDocument.h
index e11fd2ec8551..9c295e70d85f 100644
--- a/dom/html/MediaDocument.h
+++ b/dom/html/MediaDocument.h
@@ -16,6 +16,9 @@
#define NSMEDIADOCUMENT_PROPERTIES_URI \
"chrome://global/locale/layout/MediaDocument.properties"
+#define NSMEDIADOCUMENT_PROPERTIES_URI_en_US \
+ "resource://gre/res/locale/layout/MediaDocument.properties"
+
namespace mozilla {
namespace dom {
@@ -60,6 +63,9 @@ class MediaDocument : public nsHTMLDocument {
nsresult LinkStylesheet(const nsAString& aStylesheet);
nsresult LinkScript(const nsAString& aScript);
+ void FormatStringFromName(const char* aName, const char16_t** aParams,
+ uint32_t aLength, nsAString& aResult);
+
// |aFormatNames[]| needs to have four elements in the following order:
// a format name with neither dimension nor file, a format name with
// filename but w/o dimension, a format name with dimension but w/o filename,
@@ -77,6 +83,7 @@ class MediaDocument : public nsHTMLDocument {
const nsAString& aStatus = EmptyString());
nsCOMPtr<nsIStringBundle> mStringBundle;
+ nsCOMPtr<nsIStringBundle> mStringBundleEnglish;
static const char* const sFormatNames[4];
private:
diff --git a/dom/html/input/CheckableInputTypes.cpp b/dom/html/input/CheckableInputTypes.cpp
index f55000c766ea..c564c36b884a 100644
--- a/dom/html/input/CheckableInputTypes.cpp
+++ b/dom/html/input/CheckableInputTypes.cpp
@@ -23,14 +23,15 @@ bool CheckboxInputType::IsValueMissing() const {
}
nsresult CheckboxInputType::GetValueMissingMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
- "FormValidationCheckboxMissing",
- aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationCheckboxMissing",
+ mInputElement->OwnerDoc(), aMessage);
}
/* input type=radio */
nsresult RadioInputType::GetValueMissingMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationRadioMissing", aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationRadioMissing",
+ mInputElement->OwnerDoc(), aMessage);
}
diff --git a/dom/html/input/DateTimeInputTypes.cpp b/dom/html/input/DateTimeInputTypes.cpp
index 11dfc9e541b9..6d87313907f4 100644
--- a/dom/html/input/DateTimeInputTypes.cpp
+++ b/dom/html/input/DateTimeInputTypes.cpp
@@ -137,9 +137,9 @@ nsresult DateTimeInputTypeBase::GetRangeOverflowMessage(nsAString& aMessage) {
mInputElement->GetAttr(kNameSpaceID_None, nsGkAtoms::max, maxStr);
const char16_t* params[] = {maxStr.get()};
- return nsContentUtils::FormatLocalizedString(
+ return nsContentUtils::FormatMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES, "FormValidationDateTimeRangeOverflow",
- params, aMessage);
+ mInputElement->OwnerDoc(), params, aMessage);
}
nsresult DateTimeInputTypeBase::GetRangeUnderflowMessage(nsAString& aMessage) {
@@ -147,9 +147,9 @@ nsresult DateTimeInputTypeBase::GetRangeUnderflowMessage(nsAString& aMessage) {
mInputElement->GetAttr(kNameSpaceID_None, nsGkAtoms::min, minStr);
const char16_t* params[] = {minStr.get()};
- return nsContentUtils::FormatLocalizedString(
+ return nsContentUtils::FormatMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES, "FormValidationDateTimeRangeUnderflow",
- params, aMessage);
+ mInputElement->OwnerDoc(), params, aMessage);
}
nsresult DateTimeInputTypeBase::MinMaxStepAttrChanged() {
@@ -193,8 +193,9 @@ nsresult DateInputType::GetBadInputMessage(nsAString& aMessage) {
return NS_ERROR_UNEXPECTED;
}
- return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidDate", aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidDate",
+ mInputElement->OwnerDoc(), aMessage);
}
bool DateInputType::ConvertStringToNumber(
diff --git a/dom/html/input/FileInputType.cpp b/dom/html/input/FileInputType.cpp
index 2536a875b2ca..856684080825 100644
--- a/dom/html/input/FileInputType.cpp
+++ b/dom/html/input/FileInputType.cpp
@@ -21,6 +21,7 @@ bool FileInputType::IsValueMissing() const {
}
nsresult FileInputType::GetValueMissingMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationFileMissing", aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationFileMissing",
+ mInputElement->OwnerDoc(), aMessage);
}
diff --git a/dom/html/input/InputType.cpp b/dom/html/input/InputType.cpp
index 210daeafad14..51dbe9b93527 100644
--- a/dom/html/input/InputType.cpp
+++ b/dom/html/input/InputType.cpp
@@ -166,9 +166,9 @@ nsresult InputType::GetValidationMessage(
strTextLength.AppendInt(textLength);
const char16_t* params[] = {strMaxLength.get(), strTextLength.get()};
- rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooLong", params,
- message);
+ rv = nsContentUtils::FormatMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooLong",
+ mInputElement->OwnerDoc(), params, message);
aValidationMessage = message;
break;
}
@@ -184,9 +184,9 @@ nsresult InputType::GetValidationMessage(
strTextLength.AppendInt(textLength);
const char16_t* params[] = {strMinLength.get(), strTextLength.get()};
- rv = nsContentUtils::FormatLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooShort", params,
- message);
+ rv = nsContentUtils::FormatMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationTextTooShort",
+ mInputElement->OwnerDoc(), params, message);
aValidationMessage = message;
break;
@@ -216,9 +216,9 @@ nsresult InputType::GetValidationMessage(
nsAutoString title;
mInputElement->GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
if (title.IsEmpty()) {
- rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
- "FormValidationPatternMismatch",
- message);
+ rv = nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationPatternMismatch",
+ mInputElement->OwnerDoc(), message);
} else {
if (title.Length() >
nsIConstraintValidation::sContentSpecifiedMaxLengthMessage) {
@@ -226,9 +226,10 @@ nsresult InputType::GetValidationMessage(
nsIConstraintValidation::sContentSpecifiedMaxLengthMessage);
}
const char16_t* params[] = {title.get()};
- rv = nsContentUtils::FormatLocalizedString(
+ rv = nsContentUtils::FormatMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES,
- "FormValidationPatternMismatchWithTitle", params, message);
+ "FormValidationPatternMismatchWithTitle", mInputElement->OwnerDoc(),
+ params, message);
}
aValidationMessage = message;
break;
@@ -278,23 +279,25 @@ nsresult InputType::GetValidationMessage(
if (valueLowStr.Equals(valueHighStr)) {
const char16_t* params[] = {valueLowStr.get()};
- rv = nsContentUtils::FormatLocalizedString(
+ rv = nsContentUtils::FormatMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES,
- "FormValidationStepMismatchOneValue", params, message);
+ "FormValidationStepMismatchOneValue", mInputElement->OwnerDoc(),
+ params, message);
} else {
const char16_t* params[] = {valueLowStr.get(), valueHighStr.get()};
- rv = nsContentUtils::FormatLocalizedString(
+ rv = nsContentUtils::FormatMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES, "FormValidationStepMismatch",
- params, message);
+ mInputElement->OwnerDoc(), params, message);
}
} else {
nsAutoString valueLowStr;
ConvertNumberToString(valueLow, valueLowStr);
const char16_t* params[] = {valueLowStr.get()};
- rv = nsContentUtils::FormatLocalizedString(
+ rv = nsContentUtils::FormatMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES,
- "FormValidationStepMismatchOneValue", params, message);
+ "FormValidationStepMismatchOneValue", mInputElement->OwnerDoc(),
+ params, message);
}
aValidationMessage = message;
@@ -318,8 +321,9 @@ nsresult InputType::GetValidationMessage(
}
nsresult InputType::GetValueMissingMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationValueMissing", aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationValueMissing",
+ mInputElement->OwnerDoc(), aMessage);
}
nsresult InputType::GetTypeMismatchMessage(nsAString& aMessage) {
diff --git a/dom/html/input/NumericInputTypes.cpp b/dom/html/input/NumericInputTypes.cpp
index 6332e028c17e..9770ccd416b1 100644
--- a/dom/html/input/NumericInputTypes.cpp
+++ b/dom/html/input/NumericInputTypes.cpp
@@ -72,9 +72,9 @@ nsresult NumericInputTypeBase::GetRangeOverflowMessage(nsAString& aMessage) {
MOZ_ASSERT(ok, "buf not big enough");
const char16_t* params[] = {maxStr.get()};
- return nsContentUtils::FormatLocalizedString(
+ return nsContentUtils::FormatMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES, "FormValidationNumberRangeOverflow",
- params, aMessage);
+ mInputElement->OwnerDoc(), params, aMessage);
}
nsresult NumericInputTypeBase::GetRangeUnderflowMessage(nsAString& aMessage) {
@@ -89,9 +89,9 @@ nsresult NumericInputTypeBase::GetRangeUnderflowMessage(nsAString& aMessage) {
MOZ_ASSERT(ok, "buf not big enough");
const char16_t* params[] = {minStr.get()};
- return nsContentUtils::FormatLocalizedString(
+ return nsContentUtils::FormatMaybeLocalizedString(
nsContentUtils::eDOM_PROPERTIES, "FormValidationNumberRangeUnderflow",
- params, aMessage);
+ mInputElement->OwnerDoc(), params, aMessage);
}
bool NumericInputTypeBase::ConvertStringToNumber(
@@ -150,15 +150,15 @@ bool NumberInputType::HasBadInput() const {
}
nsresult NumberInputType::GetValueMissingMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
- "FormValidationBadInputNumber",
- aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationBadInputNumber",
+ mInputElement->OwnerDoc(), aMessage);
}
nsresult NumberInputType::GetBadInputMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
- "FormValidationBadInputNumber",
- aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationBadInputNumber",
+ mInputElement->OwnerDoc(), aMessage);
}
bool NumberInputType::IsMutable() const {
diff --git a/dom/html/input/SingleLineTextInputTypes.cpp b/dom/html/input/SingleLineTextInputTypes.cpp
index 15cbe65a1941..090de7466fae 100644
--- a/dom/html/input/SingleLineTextInputTypes.cpp
+++ b/dom/html/input/SingleLineTextInputTypes.cpp
@@ -116,8 +116,9 @@ bool URLInputType::HasTypeMismatch() const {
}
nsresult URLInputType::GetTypeMismatchMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidURL", aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidURL",
+ mInputElement->OwnerDoc(), aMessage);
}
/* input type=email */
@@ -154,13 +155,15 @@ bool EmailInputType::HasBadInput() const {
}
nsresult EmailInputType::GetTypeMismatchMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidEmail", aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidEmail",
+ mInputElement->OwnerDoc(), aMessage);
}
nsresult EmailInputType::GetBadInputMessage(nsAString& aMessage) {
- return nsContentUtils::GetLocalizedString(
- nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidEmail", aMessage);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eDOM_PROPERTIES, "FormValidationInvalidEmail",
+ mInputElement->OwnerDoc(), aMessage);
}
/* static */
diff --git a/dom/locales/moz.build b/dom/locales/moz.build
index b2bcd271de7c..51f4b88ccd47 100644
--- a/dom/locales/moz.build
+++ b/dom/locales/moz.build
@@ -62,4 +62,10 @@ JAR_MANIFESTS += ['jar.mn']
RESOURCE_FILES.locale.layout += [
'en-US/chrome/layout/HtmlForm.properties',
+ 'en-US/chrome/layout/MediaDocument.properties',
+ 'en-US/chrome/layout/xmlparser.properties',
+]
+
+RESOURCE_FILES.locale.dom += [
+ 'en-US/chrome/dom/dom.properties',
]
diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp
index 7a5a96d1769a..491274c9b2a6 100644
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -1654,8 +1654,8 @@ already_AddRefed<nsIContent> nsCSSFrameConstructor::CreateGeneratedContent(
}
nsAutoString temp;
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "Submit", temp);
+ nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eFORMS_PROPERTIES, "Submit", mDocument, temp);
return CreateGenConTextNode(aState, temp, nullptr, nullptr);
}
@@ -7899,8 +7899,9 @@ void nsCSSFrameConstructor::GetAlternateTextFor(Element* aElement, nsAtom* aTag,
// If there's no "value" attribute either, then use the localized string for
// "Submit" as the alternate text.
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "Submit", aAltText);
+ nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ "Submit", aElement->OwnerDoc(),
+ aAltText);
}
}
diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp
index 9be30011aa8e..8da00f76dcea 100644
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -215,8 +215,8 @@ static already_AddRefed<Element> MakeAnonButton(Document* aDoc,
// Set the file picking button text depending on the current locale.
nsAutoString buttonTxt;
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, labelKey, buttonTxt);
+ nsContentUtils::GetMaybeLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ labelKey, aDoc, buttonTxt);
// Set the browse button text. It's a bit of a pain to do because we want to
// make sure we are not notifying.
diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp
index 03186ef7bf54..fa4219a5308f 100644
--- a/layout/forms/nsGfxButtonControlFrame.cpp
+++ b/layout/forms/nsGfxButtonControlFrame.cpp
@@ -88,8 +88,8 @@ nsresult nsGfxButtonControlFrame::GetDefaultLabel(nsAString& aString) const {
return NS_OK;
}
- return nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, prop, aString);
+ return nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eFORMS_PROPERTIES, prop, mContent->OwnerDoc(), aString);
}
nsresult nsGfxButtonControlFrame::GetLabel(nsString& aLabel) {
diff --git a/layout/generic/DetailsFrame.cpp b/layout/generic/DetailsFrame.cpp
index e1a9f0c70b2b..20f93b2f328f 100644
--- a/layout/generic/DetailsFrame.cpp
+++ b/layout/generic/DetailsFrame.cpp
@@ -98,9 +98,9 @@ nsresult DetailsFrame::CreateAnonymousContent(
mDefaultSummary = new HTMLSummaryElement(nodeInfo.forget());
nsAutoString defaultSummaryText;
- nsContentUtils::GetLocalizedString(
- nsContentUtils::eFORMS_PROPERTIES_MAYBESPOOF, "DefaultSummary",
- defaultSummaryText);
+ nsContentUtils::GetMaybeLocalizedString(
+ nsContentUtils::eFORMS_PROPERTIES, "DefaultSummary",
+ GetContent()->OwnerDoc(), defaultSummaryText);
RefPtr<nsTextNode> description = new nsTextNode(nodeInfoManager);
description->SetText(defaultSummaryText, false);
mDefaultSummary->AppendChildTo(description, false);
diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in
index 2002a894fc51..33e0175a624e 100644
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -203,6 +203,9 @@
@BINPATH@/res/dtd/*
@BINPATH@/res/language.properties
@BINPATH@/res/locale/layout/HtmlForm.properties
+@BINPATH@/res/locale/layout/MediaDocument.properties
+@BINPATH@/res/locale/layout/xmlparser.properties
+@BINPATH@/res/locale/dom/dom.properties
#ifndef MOZ_ANDROID_EXCLUDE_FONTS
@BINPATH@/res/fonts/*
diff --git a/parser/htmlparser/nsExpatDriver.cpp b/parser/htmlparser/nsExpatDriver.cpp
index 73a0e65328f0..0c35f87bc321 100644
--- a/parser/htmlparser/nsExpatDriver.cpp
+++ b/parser/htmlparser/nsExpatDriver.cpp
@@ -673,12 +673,13 @@ static nsresult CreateErrorText(const char16_t* aDescription,
const char16_t* aSourceURL,
const uint32_t aLineNumber,
const uint32_t aColNumber,
- nsString& aErrorString) {
+ nsString& aErrorString, bool spoofEnglish) {
aErrorString.Truncate();
nsAutoString msg;
nsresult rv = nsParserMsgUtils::GetLocalizedStringByName(
- XMLPARSER_PROPERTIES, "XMLParsingError", msg);
+ spoofEnglish ? XMLPARSER_PROPERTIES_en_US : XMLPARSER_PROPERTIES,
+ "XMLParsingError", msg);
NS_ENSURE_SUCCESS(rv, rv);
// XML Parsing Error: %1$S\nLocation: %2$S\nLine Number %3$u, Column %4$u:
@@ -719,8 +720,15 @@ nsresult nsExpatDriver::HandleError() {
// Map Expat error code to an error string
// XXX Deal with error returns.
nsAutoString description;
- nsParserMsgUtils::GetLocalizedStringByID(XMLPARSER_PROPERTIES, code,
- description);
+ nsCOMPtr<Document> doc;
+ if (mOriginalSink) {
+ doc = do_QueryInterface(mOriginalSink->GetTarget());
+ }
+ bool spoofEnglish =
+ nsContentUtils::SpoofLocaleEnglish() && (!doc || !doc->AllowsL10n());
+ nsParserMsgUtils::GetLocalizedStringByID(
+ spoofEnglish ? XMLPARSER_PROPERTIES_en_US : XMLPARSER_PROPERTIES, code,
+ description);
if (code == XML_ERROR_TAG_MISMATCH) {
/**
@@ -756,8 +764,9 @@ nsresult nsExpatDriver::HandleError() {
tagName.Append(nameStart, (nameEnd ? nameEnd : pos) - nameStart);
nsAutoString msg;
- nsParserMsgUtils::GetLocalizedStringByName(XMLPARSER_PROPERTIES, "Expected",
- msg);
+ nsParserMsgUtils::GetLocalizedStringByName(
+ spoofEnglish ? XMLPARSER_PROPERTIES_en_US : XMLPARSER_PROPERTIES,
+ "Expected", msg);
// . Expected: </%S>.
nsAutoString message;
@@ -771,7 +780,7 @@ nsresult nsExpatDriver::HandleError() {
nsAutoString errorText;
CreateErrorText(description.get(), XML_GetBase(mExpatParser), lineNumber,
- colNumber, errorText);
+ colNumber, errorText, spoofEnglish);
nsAutoString sourceText(mLastLine);
AppendErrorPointer(colNumber, mLastLine.get(), sourceText);
diff --git a/parser/htmlparser/nsParserMsgUtils.h b/parser/htmlparser/nsParserMsgUtils.h
index b4ec4784d65f..3645610385c1 100644
--- a/parser/htmlparser/nsParserMsgUtils.h
+++ b/parser/htmlparser/nsParserMsgUtils.h
@@ -11,6 +11,9 @@
#define XMLPARSER_PROPERTIES \
"chrome://global/locale/layout/xmlparser.properties"
+#define XMLPARSER_PROPERTIES_en_US \
+ "resource://gre/res/locale/layout/xmlparser.properties"
+
class nsParserMsgUtils {
nsParserMsgUtils(); // Currently this is not meant to be created, use the
// static methods
1
0
commit eab41780abd544091ebb532b128c6d6d07087a70
Author: Georg Koppen <gk(a)torproject.org>
Date: Mon Nov 4 12:20:38 2019 +0000
Pick up better fix for #32342
---
rbm.conf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rbm.conf b/rbm.conf
index 8bd5805..727c09f 100644
--- a/rbm.conf
+++ b/rbm.conf
@@ -25,7 +25,7 @@ buildconf:
var:
torbrowser_version: '9.5a2'
- torbrowser_build: 'build3'
+ torbrowser_build: 'build4'
torbrowser_incremental_from:
- 9.5a1
project_name: tor-browser
1
0

[tor-browser-build/master] Revert "Bug 32342 - Store omni.ja after recreating apk"
by gk@torproject.org 04 Nov '19
by gk@torproject.org 04 Nov '19
04 Nov '19
commit d8f62baa1d4436e90db842cc8ab42b4454b87684
Author: Nicolas Vigier <boklm(a)torproject.org>
Date: Mon Nov 4 12:15:35 2019 +0100
Revert "Bug 32342 - Store omni.ja after recreating apk"
This reverts commit 3c7fb0e610a4f85d7b157221ac9049d99d958c24.
---
projects/tor-browser/build.android | 4 ----
1 file changed, 4 deletions(-)
diff --git a/projects/tor-browser/build.android b/projects/tor-browser/build.android
index 5148c36..2c1c3b2 100644
--- a/projects/tor-browser/build.android
+++ b/projects/tor-browser/build.android
@@ -54,9 +54,5 @@ cd tmp
zip_args => '$apk',
}) %]
-# omni.ja was likely deflated in the above zipping operation. It must be stored, instead.
-zip $apk -d assets/omni.ja
-zip -Z store $apk assets/omni.ja
-
# Sign a QA build. This apk is not a debug version and doesn't contain a debug flag in the manifest
java -jar /usr/share/apksigner/apksigner.jar sign --verbose --min-sdk-version [% c("var/android_min_api") %] --ks $rootdir/android-qa.keystore --out $qa_apk --in $apk --ks-key-alias androidqakey --key-pass pass:android --ks-pass pass:android
1
0