tor-commits
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- 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
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
November 2019
- 20 participants
- 2924 discussions
[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
[tor/master] Remove 00-overview.md as already subsumed by doxygen
by nickm@torproject.org 06 Nov '19
by nickm@torproject.org 06 Nov '19
06 Nov '19
commit 83cab0539817148405e44e1847d757fb2f57b79b
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Wed Nov 6 15:47:00 2019 -0500
Remove 00-overview.md as already subsumed by doxygen
---
doc/HACKING/design/00-overview.md | 25 -------------------------
1 file changed, 25 deletions(-)
diff --git a/doc/HACKING/design/00-overview.md b/doc/HACKING/design/00-overview.md
deleted file mode 100644
index 1c14dc8c1..000000000
--- a/doc/HACKING/design/00-overview.md
+++ /dev/null
@@ -1,25 +0,0 @@
-
-## Overview ##
-
-
-### The rest of this document. ###
-
-> **Note**: This section describes the eventual organization of this
-> document, which is not yet complete.
-
-We'll begin with an overview of the facilities provided by the modules
-in src/lib. Knowing about these is key to writing portable, simple code
-in Tor.
-
-Then we'll move on to a discussion of how parts of the Tor codebase are
-initialized, finalized, configured, and managed.
-
-Then we'll go on and talk about the main data-flow of the Tor network:
-how Tor generates and responds to network traffic. This will occupy a
-chapter for the main overview, with other chapters for special topics.
-
-After that, we'll mention the main modules in src/features and describe the
-functions of each.
-
-We'll close with a meandering overview of important pending issues in
-the Tor codebase, and how they affect the future of the Tor software.
1
0
commit 58d7f9e68bfa69f831ed81c5e7924d32c1c2d764
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Wed Nov 6 15:47:29 2019 -0500
Remove Makefile from doc/HACKING/design
---
doc/HACKING/design/Makefile | 34 ----------------------------------
1 file changed, 34 deletions(-)
diff --git a/doc/HACKING/design/Makefile b/doc/HACKING/design/Makefile
deleted file mode 100644
index e12613097..000000000
--- a/doc/HACKING/design/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-HTML= \
- 00-overview.html \
- 01-common-utils.html \
- 01a-memory.html \
- 01b-collections.html \
- 01c-time.html \
- 01d-crypto.html \
- 01e-os-compat.html \
- 01f-threads.html \
- 01g-strings.html \
- 02-dataflow.html \
- 03-modules.html \
- this-not-that.html
-
-PNG = \
- diagrams/02/02-dataflow.png \
- diagrams/02/02-connection-types.png
-
-all: generated
-
-generated: $(HTML) $(PNG)
-
-%.html: %.md
- maruku $< -o $@
-
-%.png: %.dia
- dia $< --export=$@
-
-clean:
- rm -f $(HTML)
- rm -f $(PNG)
1
0
[translation/snowflakeaddon-messages.json] https://gitweb.torproject.org/translation.git/commit/?h=snowflakeaddon-messages.json
by translation@torproject.org 06 Nov '19
by translation@torproject.org 06 Nov '19
06 Nov '19
commit 4a8936b010f45c29c3c648c3b6d6ec7b51b43d8a
Author: Translation commit bot <translation(a)torproject.org>
Date: Wed Nov 6 20:47:25 2019 +0000
https://gitweb.torproject.org/translation.git/commit/?h=snowflakeaddon-mess…
---
nl/messages.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nl/messages.json b/nl/messages.json
index 76f2e76ba..0daf5e6f0 100644
--- a/nl/messages.json
+++ b/nl/messages.json
@@ -30,7 +30,7 @@
"message": "Cookies zijn niet ingeschakeld."
},
"websiteIntro": {
- "message": "Snowflake is a system to defeat internet censorship. People who are censored can use Snowflake to access the internet. Their connection goes through Snowflake proxies, which are run by volunteers. For more detailed information about how Snowflake works see our <a href=\"https://trac.torproject.org/projects/tor/wiki/doc/Snowflake/\" data-msgid=\"__MSG_docWiki__\">documentation wiki</a>."
+ "message": "Snowflake is een systeem om internetcensuur te verslaan. Gecensureerde personen kunnen Snowflake gebruiken om toegang te krijgen tot het internet. Hun verbinding loopt via Snowflake-proxy’s, die door vrijwilligers worden beheerd. Bekijk onze <a href=\"https://trac.torproject.org/projects/tor/wiki/doc/Snowflake/\" data-msgid=\"__MSG_docWiki__\">documentatie-wiki</a> voor meer gedetailleerde informatie over de werking van Snowflake."
},
"docWiki": {
"message": "documentatie-wiki"
1
0
[translation/orfox-stringsxml_completed] https://gitweb.torproject.org/translation.git/commit/?h=orfox-stringsxml_completed
by translation@torproject.org 06 Nov '19
by translation@torproject.org 06 Nov '19
06 Nov '19
commit e23e4b83d3518d61e563f4297e081d8dd0a13ebf
Author: Translation commit bot <translation(a)torproject.org>
Date: Wed Nov 6 20:47:05 2019 +0000
https://gitweb.torproject.org/translation.git/commit/?h=orfox-stringsxml_co…
---
nn-NO/strings.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/nn-NO/strings.xml b/nn-NO/strings.xml
new file mode 100644
index 000000000..cb5acbb4f
--- /dev/null
+++ b/nn-NO/strings.xml
@@ -0,0 +1,2 @@
+<resources>
+ </resources>
1
0
[translation/orfox-stringsxml] https://gitweb.torproject.org/translation.git/commit/?h=orfox-stringsxml
by translation@torproject.org 06 Nov '19
by translation@torproject.org 06 Nov '19
06 Nov '19
commit c1e245605a7b14d963aaaf69031fc3e02d34e861
Author: Translation commit bot <translation(a)torproject.org>
Date: Wed Nov 6 20:46:56 2019 +0000
https://gitweb.torproject.org/translation.git/commit/?h=orfox-stringsxml
---
nn-NO/strings.xml | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/nn-NO/strings.xml b/nn-NO/strings.xml
index cb5acbb4f..db5c19b73 100644
--- a/nn-NO/strings.xml
+++ b/nn-NO/strings.xml
@@ -1,2 +1,10 @@
<resources>
- </resources>
+ <string name="app_name">OrfoxRIP</string>
+ <string name="try_tor_browser">Prøv nettlesaren Tor</string>
+ <string name="orfox_is_now_tor_browser">Orfox er no nettlesaren Tor for Android.</string>
+ <string name="get_it">Last ned frå føretrekt kjelde:</string>
+ <string name="go_to_f_droid">GÅ TIL F-DROID</string>
+ <string name="go_to_google_play">GÅ TIL GOOGLE PLAY</string>
+ <string name="download_apk">LAST NED .APK</string>
+ <string name="export_bookmarks">Eksporter bokmerke</string>
+</resources>
1
0
[translation/https_everywhere_completed] https://gitweb.torproject.org/translation.git/commit/?h=https_everywhere_completed
by translation@torproject.org 06 Nov '19
by translation@torproject.org 06 Nov '19
06 Nov '19
commit 247ee0b6bb07da4593dc195e6dba4c3e6efcec3e
Author: Translation commit bot <translation(a)torproject.org>
Date: Wed Nov 6 20:16:07 2019 +0000
https://gitweb.torproject.org/translation.git/commit/?h=https_everywhere_co…
---
de/https-everywhere.dtd | 109 ++++++++++++++++++++++++------------------------
1 file changed, 55 insertions(+), 54 deletions(-)
diff --git a/de/https-everywhere.dtd b/de/https-everywhere.dtd
index 5ff112754..5e483a373 100644
--- a/de/https-everywhere.dtd
+++ b/de/https-everywhere.dtd
@@ -2,66 +2,67 @@
<!ENTITY https-everywhere.about.ext_name "HTTPS Everywhere">
<!ENTITY https-everywhere.about.ext_description "Verschlüsselt das Internet! Nutzen Sie HTTPS-Sicherheit automatisch auf vielen Webseiten.">
<!ENTITY https-everywhere.about.version "Version">
-<!ENTITY https-everywhere.about.rulesets_version "Regelset Version für">
-<!ENTITY https-everywhere.about.add_new_rule "Neue Regel hinzufügen">
+<!ENTITY https-everywhere.about.rulesets_version "">
+<!ENTITY https-everywhere.about.add_new_rule "">
-<!ENTITY https-everywhere.menu.donate_eff_imperative "Spende an EFF">
+<!ENTITY https-everywhere.menu.donate_eff_imperative "">
<!ENTITY https-everywhere.menu.observatory "SSL-Observatory-Einstellungen">
-<!ENTITY https-everywhere.menu.globalDisable "HTTPS Everywhere ist AUS">
-<!ENTITY https-everywhere.menu.globalEnable "HTTPS Everywhere ist AN">
-<!ENTITY https-everywhere.menu.encryptAllSitesEligibleOn "Alle geeigneten Seiten verschlüsseln ist AN">
-<!ENTITY https-everywhere.menu.encryptAllSitesEligibleOff "Alle geeigneten Seiten verschlüsseln ist AUS">
-<!ENTITY https-everywhere.menu.httpNoWhereExplainedBlocked "Unverschlüsselte Anfragen sind derzeit blockiert.">
-<!ENTITY https-everywhere.menu.httpNoWhereExplainedAllowed "Unverschlüsselte Anfragen sind derzeit erlaubt">
-<!ENTITY https-everywhere.menu.seeMore "Weitere Informationen">
-<!ENTITY https-everywhere.menu.seeLess "Weniger anzeigen">
-<!ENTITY https-everywhere.menu.httpNoWhereMore "Dieser Modus blockiert unverschlüsselte Inhalte und Anfragen.">
+<!ENTITY https-everywhere.menu.globalDisable "">
+<!ENTITY https-everywhere.menu.globalEnable "">
+<!ENTITY https-everywhere.menu.encryptAllSitesEligibleOn "">
+<!ENTITY https-everywhere.menu.encryptAllSitesEligibleOff "">
+<!ENTITY https-everywhere.menu.httpNoWhereExplainedBlocked "">
+<!ENTITY https-everywhere.menu.httpNoWhereExplainedAllowed "">
+<!ENTITY https-everywhere.menu.seeMore "">
+<!ENTITY https-everywhere.menu.seeLess "">
+<!ENTITY https-everywhere.menu.httpNoWhereMore "">
<!ENTITY https-everywhere.menu.showCounter "Zähler anzeigen">
<!ENTITY https-everywhere.menu.viewAllRules "Alle Regeln ansehen">
-<!ENTITY https-everywhere.options.settings "Einstellungen">
-<!ENTITY https-everywhere.options.generalSettings "Allgemeine Einstellungen">
-<!ENTITY https-everywhere.options.advancedSettings "Erweiterte Einstellungen">
-<!ENTITY https-everywhere.options.updateChannels "Aktualisierungs-Quellen">
-<!ENTITY https-everywhere.options.enableMixedRulesets "Regelsätze für gemischte Inhalte aktivieren">
-<!ENTITY https-everywhere.options.showDevtoolsTab "Entwicklungswerkzeuge-Reiter anzeigen">
-<!ENTITY https-everywhere.options.autoUpdateRulesets "Regelsätze automatisch aktualisieren">
-<!ENTITY https-everywhere.options.userRulesListed "HTTPS Everywhere Benutzerregeln">
-<!ENTITY https-everywhere.options.disabledUrlsListed "HTTPS Everywhere deaktivierte Webseiten">
-<!ENTITY https-everywhere.options.updateChannelsWarning "Warnung: Das Hinzufügen neuer Quellen könnte es Angreifern erlauben, den Browser zu übernehmen. Dieser Bereich sollte nur bearbeitet werden, wenn Sie wissen, was Sie tun.">
-<!ENTITY https-everywhere.options.addUpdateChannel "Aktualisierungs-Quelle hinzufügen">
-<!ENTITY https-everywhere.options.enterUpdateChannelName "Name der Aktualisierungs-Quelle eingeben">
-<!ENTITY https-everywhere.options.delete "Entf">
-<!ENTITY https-everywhere.options.update "Speichern">
-<!ENTITY https-everywhere.options.storedRulesetsVersion "Regelsatz-Version:">
-<!ENTITY https-everywhere.options.updatesLastChecked "Letzte Aktualisierung:">
-<!ENTITY https-everywhere.options.updatesLastCheckedNever "nie">
-<!ENTITY https-everywhere.options.debuggingRulesets "Fehlerdiagnose von Regelsätzen (erweitert)">
+<!ENTITY https-everywhere.options.settings "">
+<!ENTITY https-everywhere.options.generalSettings "">
+<!ENTITY https-everywhere.options.advancedSettings "">
+<!ENTITY https-everywhere.options.updateChannels "">
+<!ENTITY https-everywhere.options.enableMixedRulesets "">
+<!ENTITY https-everywhere.options.showDevtoolsTab "">
+<!ENTITY https-everywhere.options.autoUpdateRulesets "">
+<!ENTITY https-everywhere.options.userRulesListed "">
+<!ENTITY https-everywhere.options.disabledUrlsListed "">
+<!ENTITY https-everywhere.options.updateChannelsWarning "">
+<!ENTITY https-everywhere.options.addUpdateChannel "">
+<!ENTITY https-everywhere.options.enterUpdateChannelName "">
+<!ENTITY https-everywhere.options.delete "">
+<!ENTITY https-everywhere.options.update "">
+<!ENTITY https-everywhere.options.storedRulesetsVersion "">
+<!ENTITY https-everywhere.options.updatesLastChecked "">
+<!ENTITY https-everywhere.options.updatesLastCheckedNever "">
+<!ENTITY https-everywhere.options.debuggingRulesets "">
-<!ENTITY https-everywhere.prefs.export_settings "Einstellungen exportieren">
+<!ENTITY https-everywhere.prefs.export_settings "">
<!ENTITY https-everywhere.prefs.reset_defaults "Auf Standardeinstellungen zurücksetzen">
-<!ENTITY https-everywhere.prefs.reset_defaults_message "Dies wird jeden Regelsatz auf seinen Standardzustand zurücksetzen. Fortfahren?">
+<!ENTITY https-everywhere.prefs.reset_defaults_message "">
-<!ENTITY https-everywhere.cancel.he_blocking_explainer "HTTPS Everywhere hat bemerkt, dass du zu einer Nicht-HTTPS-Seite navigierst, und versuchte, dich stattdessen an die HTTPS-Version zu schicken. Die HTTPS-Version ist nicht verfügbar. Wahrscheinlich unterstützt diese Seite kein HTTPS, aber es ist auch möglich, dass ein Angreifer die HTTPS-Version blockiert. Wenn du die unverschlüsselte Version dieser Seite anzeigen möchtest, kannst du dies trotzdem tun, indem du die Option 'Alle geeigneten Seiten verschlüsseln' (EASE) in deiner HTTPS Everywhere Erweiterung deaktivierst. Beachte, dass das Deaktivieren dieser Option deinen Browser anfällig für netzwerkbasierte Downgrade-Angriffe auf von dir besuchte Websites machen kann.">
-<!ENTITY https-everywhere.cancel.he_blocking_network "Netzwerk-basierte Downgrade Angriffe">
-<!ENTITY https-everywhere.cancel.open_page "Unsichere Seite öffnen">
+<!ENTITY https-everywhere.cancel.he_blocking_explainer "">
+<!ENTITY https-everywhere.cancel.he_blocking_network "">
+<!ENTITY https-everywhere.cancel.open_page "">
+<!ENTITY https-everywhere.cancel.http_once "">
-<!ENTITY https-everywhere.chrome.settings_for_this_site_header "Einstellungen für diese Seite">
-<!ENTITY https-everywhere.chrome.settings_for_this_site_subheader "Ändere deine Einstellungen für verschlüsselte Verbindungen.">
-<!ENTITY https-everywhere.chrome.settings_for_this_site_explained "Wenn du verschiedene Webseiten besuchst, kannst du deine Einstellungen für jede Webseite ändern">
-<!ENTITY https-everywhere.chrome.stable_rules "Funktionierende Regeln">
-<!ENTITY https-everywhere.chrome.stable_rules_description "Erzwingen Sie eine verschlüsselte Verbindung zu diesen Webseiten:">
-<!ENTITY https-everywhere.chrome.experimental_rules "Experimentelle Regeln">
-<!ENTITY https-everywhere.chrome.experimental_rules_description "Kann Warnungen oder Abstürze verursachen. Standardmäßig deaktiviert.">
-<!ENTITY https-everywhere.chrome.disable_on_this_site "HTTPS Everywhere auf dieser Website deaktivieren">
-<!ENTITY https-everywhere.chrome.enable_on_this_site "HTTPS Everywhere auf dieser Website aktivieren">
-<!ENTITY https-everywhere.chrome.add_rule "Erstelle eine Regel für diese Seite">
-<!ENTITY https-everywhere.chrome.add_new_rule "Erstelle eine neue Regel für diese Seite">
-<!ENTITY https-everywhere.chrome.always_https_for_host "Benutze immer https für diesen host">
-<!ENTITY https-everywhere.chrome.host "Host:">
-<!ENTITY https-everywhere.chrome.show_advanced "Erweiterte Optionen anzeigen">
-<!ENTITY https-everywhere.chrome.hide_advanced "Erweiterte Optionen ausblenden">
-<!ENTITY https-everywhere.chrome.rule_name "Regelname">
-<!ENTITY https-everywhere.chrome.regex "Übereinstimmende regex">
-<!ENTITY https-everywhere.chrome.redirect_to "Weiterleiten nach">
-<!ENTITY https-everywhere.chrome.status_cancel_button "Abbrechen">
+<!ENTITY https-everywhere.chrome.settings_for_this_site_header "">
+<!ENTITY https-everywhere.chrome.settings_for_this_site_subheader "">
+<!ENTITY https-everywhere.chrome.settings_for_this_site_explained "">
+<!ENTITY https-everywhere.chrome.stable_rules "">
+<!ENTITY https-everywhere.chrome.stable_rules_description "">
+<!ENTITY https-everywhere.chrome.experimental_rules "">
+<!ENTITY https-everywhere.chrome.experimental_rules_description "">
+<!ENTITY https-everywhere.chrome.disable_on_this_site "">
+<!ENTITY https-everywhere.chrome.enable_on_this_site "">
+<!ENTITY https-everywhere.chrome.add_rule "">
+<!ENTITY https-everywhere.chrome.add_new_rule "">
+<!ENTITY https-everywhere.chrome.always_https_for_host "">
+<!ENTITY https-everywhere.chrome.host "">
+<!ENTITY https-everywhere.chrome.show_advanced "">
+<!ENTITY https-everywhere.chrome.hide_advanced "">
+<!ENTITY https-everywhere.chrome.rule_name "">
+<!ENTITY https-everywhere.chrome.regex "">
+<!ENTITY https-everywhere.chrome.redirect_to "">
+<!ENTITY https-everywhere.chrome.status_cancel_button "">
1
0
[translation/https_everywhere] https://gitweb.torproject.org/translation.git/commit/?h=https_everywhere
by translation@torproject.org 06 Nov '19
by translation@torproject.org 06 Nov '19
06 Nov '19
commit d1b00fcce52f7bbb9ed7e77c8a2aa21cab1de476
Author: Translation commit bot <translation(a)torproject.org>
Date: Wed Nov 6 20:16:00 2019 +0000
https://gitweb.torproject.org/translation.git/commit/?h=https_everywhere
---
de/https-everywhere.dtd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/de/https-everywhere.dtd b/de/https-everywhere.dtd
index 1f2ccab6e..f47442697 100644
--- a/de/https-everywhere.dtd
+++ b/de/https-everywhere.dtd
@@ -45,7 +45,7 @@
<!ENTITY https-everywhere.cancel.he_blocking_explainer "HTTPS Everywhere hat bemerkt, dass du zu einer Nicht-HTTPS-Seite navigierst, und versuchte, dich stattdessen an die HTTPS-Version zu schicken. Die HTTPS-Version ist nicht verfügbar. Wahrscheinlich unterstützt diese Seite kein HTTPS, aber es ist auch möglich, dass ein Angreifer die HTTPS-Version blockiert. Wenn du die unverschlüsselte Version dieser Seite anzeigen möchtest, kannst du dies trotzdem tun, indem du die Option 'Alle geeigneten Seiten verschlüsseln' (EASE) in deiner HTTPS Everywhere Erweiterung deaktivierst. Beachte, dass das Deaktivieren dieser Option deinen Browser anfällig für netzwerkbasierte Downgrade-Angriffe auf von dir besuchte Websites machen kann.">
<!ENTITY https-everywhere.cancel.he_blocking_network "Netzwerk-basierte Downgrade Angriffe">
<!ENTITY https-everywhere.cancel.open_page "Unsichere Seite öffnen">
-<!ENTITY https-everywhere.cancel.http_once "Open insecure page for this session only">
+<!ENTITY https-everywhere.cancel.http_once "Unsichere Seite nur für diese Sitzung öffnen">
<!ENTITY https-everywhere.chrome.settings_for_this_site_header "Einstellungen für diese Seite">
<!ENTITY https-everywhere.chrome.settings_for_this_site_subheader "Ändere deine Einstellungen für verschlüsselte Verbindungen.">
1
0
06 Nov '19
commit 9687efb386141e5fc46ab295b32bf2dff1f9845b
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Wed Nov 6 14:40:20 2019 -0500
Add a bunch of doxygen for things in src/lib.
---
src/lib/arch/bytes.h | 21 ++++++++++++--
src/lib/ctime/di_ops.c | 3 ++
src/lib/ctime/di_ops.h | 23 +++++++++++++++-
src/lib/defs/time.h | 2 +-
src/lib/defs/x25519_sizes.h | 8 ++++++
src/lib/fdio/fdio.c | 7 +++--
src/lib/geoip/country.h | 1 +
src/lib/geoip/geoip.c | 16 +++++++----
src/lib/geoip/geoip.h | 1 +
src/lib/lock/compat_mutex.h | 5 ++++
src/lib/lock/compat_mutex_pthreads.c | 6 ++++
src/lib/memarea/memarea.h | 3 ++
src/lib/pubsub/pubsub_build.h | 5 ++++
src/lib/pubsub/pubsub_check.c | 2 ++
src/lib/pubsub/pubsub_macros.h | 8 +++---
src/lib/subsys/subsys.h | 12 ++++++--
src/lib/testsupport/testsupport.h | 53 ++++++++++++++++++++++++++++++------
src/lib/version/git_revision.c | 6 ++++
src/lib/version/version.c | 4 +++
src/lib/wallclock/approx_time.c | 6 ++++
20 files changed, 165 insertions(+), 27 deletions(-)
diff --git a/src/lib/arch/bytes.h b/src/lib/arch/bytes.h
index 4756ca2be..245dc94bb 100644
--- a/src/lib/arch/bytes.h
+++ b/src/lib/arch/bytes.h
@@ -16,12 +16,17 @@
#include <string.h>
#include "lib/cc/torint.h"
-/* The uint8 variants are defined to make the code more uniform. */
+/**
+ * Read an 8-bit from <b>cp</b>.
+ */
static inline uint8_t
get_uint8(const void *cp)
{
return *(const uint8_t*)(cp);
}
+/**
+ * Store an 8-bit value from <b>v</b> to <b>cp</b>.
+ */
static inline void
set_uint8(void *cp, uint8_t v)
{
@@ -93,7 +98,7 @@ set_uint64(void *cp, uint64_t v)
memcpy(cp,&v,8);
}
-#ifdef WORDS_BIGENDIAN
+#if defined(WORDS_BIGENDIAN)
static inline uint16_t
tor_htons(uint32_t a)
{
@@ -130,6 +135,9 @@ tor_ntohll(uint64_t a)
return a;
}
#else /* !defined(WORDS_BIGENDIAN) */
+/**
+ * Convert a 16-bit value from host order to network order (big-endian).
+ **/
static inline uint16_t
tor_htons(uint16_t a)
{
@@ -139,12 +147,18 @@ tor_htons(uint16_t a)
((a & 0xff00) >> 8);
}
+/**
+ * Convert a 16-bit value from network order (big-endian) to host order.
+ **/
static inline uint16_t
tor_ntohs(uint16_t a)
{
return tor_htons(a);
}
+/**
+ * Convert a 32-bit value from host order to network order (big-endian).
+ **/
static inline uint32_t
tor_htonl(uint32_t a)
{
@@ -156,6 +170,9 @@ tor_htonl(uint32_t a)
((a & 0xff000000) >>24);
}
+/**
+ * Convert a 32-bit value from network order (big-endian) to host order.
+ **/
static inline uint32_t
tor_ntohl(uint32_t a)
{
diff --git a/src/lib/ctime/di_ops.c b/src/lib/ctime/di_ops.c
index 89e0837ae..a96a888b0 100644
--- a/src/lib/ctime/di_ops.c
+++ b/src/lib/ctime/di_ops.c
@@ -145,8 +145,11 @@ tor_memeq(const void *a, const void *b, size_t sz)
/* Implement di_digest256_map_t as a linked list of entries. */
struct di_digest256_map_t {
+ /** Pointer to the next entry in the list. */
struct di_digest256_map_t *next;
+ /** Key for this entry. */
uint8_t key[32];
+ /** Value for this entry. */
void *val;
};
diff --git a/src/lib/ctime/di_ops.h b/src/lib/ctime/di_ops.h
index 264b56a8c..fea8f93e3 100644
--- a/src/lib/ctime/di_ops.h
+++ b/src/lib/ctime/di_ops.h
@@ -16,6 +16,8 @@
int tor_memcmp(const void *a, const void *b, size_t sz);
int tor_memeq(const void *a, const void *b, size_t sz);
+/** Perform a constant-time comparison of the <b>sz</b> bytes at <b>a</b> and
+ * <b>b</b>, yielding true if they are different, and false otherwise. */
#define tor_memneq(a,b,sz) (!tor_memeq((a),(b),(sz)))
/** Alias for the platform's memcmp() function. This function is
@@ -24,7 +26,19 @@ int tor_memeq(const void *a, const void *b, size_t sz);
* implementation.
*/
#define fast_memcmp(a,b,c) (memcmp((a),(b),(c)))
+/** Alias for the platform's memcmp() function, for use in testing equality.
+ *
+ * This function is <em>not</em> data-independent: we define this alias so
+ * that we can mark cases where we are deliberately using a data-dependent
+ * memcmp() implementation.
+ */
#define fast_memeq(a,b,c) (0==memcmp((a),(b),(c)))
+/** Alias for the platform's memcmp() function, for use in testing inequality.
+ *
+ * This function is <em>not</em> data-independent: we define this alias so
+ * that we can mark cases where we are deliberately using a data-dependent
+ * memcmp() implementation.
+ */
#define fast_memneq(a,b,c) (0!=memcmp((a),(b),(c)))
int safe_mem_is_zero(const void *mem, size_t sz);
@@ -35,9 +49,17 @@ int safe_mem_is_zero(const void *mem, size_t sz);
*
* Not efficient for large maps! */
typedef struct di_digest256_map_t di_digest256_map_t;
+/**
+ * Type for a function used to free members of a di_digest256_map_t.
+ **/
typedef void (*dimap_free_fn)(void *);
void dimap_free_(di_digest256_map_t *map, dimap_free_fn free_fn);
+/**
+ * @copydoc dimap_free_
+ *
+ * Additionally, set the pointer <b>map</b> to NULL.
+ **/
#define dimap_free(map, free_fn) \
do { \
dimap_free_((map), (free_fn)); \
@@ -52,4 +74,3 @@ int select_array_member_cumulative_timei(const uint64_t *entries,
uint64_t total, uint64_t rand_val);
#endif /* !defined(TOR_DI_OPS_H) */
-
diff --git a/src/lib/defs/time.h b/src/lib/defs/time.h
index 459afbf42..160970270 100644
--- a/src/lib/defs/time.h
+++ b/src/lib/defs/time.h
@@ -17,7 +17,7 @@
#define TOR_USEC_PER_SEC (1000000)
/** How many nanoseconds per microsecond */
#define TOR_NSEC_PER_USEC (1000)
-/* How many nanoseconds per millisecond */
+/** How many nanoseconds per millisecond */
#define TOR_NSEC_PER_MSEC (1000*1000)
#endif /* !defined(TOR_TIME_DEFS_H) */
diff --git a/src/lib/defs/x25519_sizes.h b/src/lib/defs/x25519_sizes.h
index 6431f0a2d..080bb4282 100644
--- a/src/lib/defs/x25519_sizes.h
+++ b/src/lib/defs/x25519_sizes.h
@@ -23,14 +23,22 @@
/** Length of the result of a curve25519 handshake. */
#define CURVE25519_OUTPUT_LEN 32
+/** Length of an Ed25519 public key */
#define ED25519_PUBKEY_LEN 32
+/** Length of an Ed25519 secret key */
#define ED25519_SECKEY_LEN 64
+/** Length of the seed that is ordinarily expanded to an Ed25519 secret
+ * key. */
#define ED25519_SECKEY_SEED_LEN 32
+/** Length of an Ed25519 signature. */
#define ED25519_SIG_LEN 64
+/** Length of a Curve25519 key when encoded in base 64, with padding. */
#define CURVE25519_BASE64_PADDED_LEN 44
+/** Length of a Ed25519 key when encoded in base 64, without padding. */
#define ED25519_BASE64_LEN 43
+/** Length of a Ed25519 signature when encoded in base 64, without padding. */
#define ED25519_SIG_BASE64_LEN 86
#endif /* !defined(TOR_X25519_SIZES_H) */
diff --git a/src/lib/fdio/fdio.c b/src/lib/fdio/fdio.c
index 078af6a9b..bfda26a43 100644
--- a/src/lib/fdio/fdio.c
+++ b/src/lib/fdio/fdio.c
@@ -28,9 +28,10 @@
#include <stdlib.h>
#include <stdio.h>
-/** @{ */
-/** Some old versions of Unix didn't define constants for these values,
+/* Some old versions of Unix didn't define constants for these values,
* and instead expect you to say 0, 1, or 2. */
+
+/** @cond */
#ifndef SEEK_SET
#define SEEK_SET 0
#endif
@@ -40,7 +41,7 @@
#ifndef SEEK_END
#define SEEK_END 2
#endif
-/** @} */
+/** @endcond */
/** Return the position of <b>fd</b> with respect to the start of the file. */
off_t
diff --git a/src/lib/geoip/country.h b/src/lib/geoip/country.h
index 2bff4f447..e6d7d77e7 100644
--- a/src/lib/geoip/country.h
+++ b/src/lib/geoip/country.h
@@ -16,6 +16,7 @@
/** A signed integer representing a country code. */
typedef int16_t country_t;
+/** Maximum value for country_t. */
#define COUNTRY_MAX INT16_MAX
#endif /* !defined(TOR_COUNTRY_H) */
diff --git a/src/lib/geoip/geoip.c b/src/lib/geoip/geoip.c
index 70b1c2dc8..2e0be13c0 100644
--- a/src/lib/geoip/geoip.c
+++ b/src/lib/geoip/geoip.c
@@ -70,12 +70,18 @@ static smartlist_t *geoip_countries = NULL;
* The index is encoded in the pointer, and 1 is added so that NULL can mean
* not found. */
static strmap_t *country_idxplus1_by_lc_code = NULL;
-/** Lists of all known geoip_ipv4_entry_t and geoip_ipv6_entry_t, sorted
- * by their respective ip_low. */
-static smartlist_t *geoip_ipv4_entries = NULL, *geoip_ipv6_entries = NULL;
-
-/** SHA1 digest of the GeoIP files to include in extra-info descriptors. */
+/** List of all known geoip_ipv4_entry_t sorted
+ * by their respective ip_low values. */
+static smartlist_t *geoip_ipv4_entries = NULL;
+/** List of all known geoip_ipv6_entry_t, sorted by their respective
+ * ip_low values. */
+static smartlist_t *geoip_ipv6_entries = NULL;
+
+/** SHA1 digest of the IPv4 GeoIP file to include in extra-info
+ * descriptors. */
static char geoip_digest[DIGEST_LEN];
+/** SHA1 digest of the IPv6 GeoIP file to include in extra-info
+ * descriptors. */
static char geoip6_digest[DIGEST_LEN];
/** Return a list of geoip_country_t for all known countries. */
diff --git a/src/lib/geoip/geoip.h b/src/lib/geoip/geoip.h
index f872ebd25..1407d0a1e 100644
--- a/src/lib/geoip/geoip.h
+++ b/src/lib/geoip/geoip.h
@@ -31,6 +31,7 @@ int geoip_get_country_by_ipv6(const struct in6_addr *addr);
/** A per-country GeoIP record. */
typedef struct geoip_country_t {
+ /** A nul-terminated two-letter country-code. */
char countrycode[3];
} geoip_country_t;
diff --git a/src/lib/lock/compat_mutex.h b/src/lib/lock/compat_mutex.h
index e0c3d7cb7..6fd4c1eb0 100644
--- a/src/lib/lock/compat_mutex.h
+++ b/src/lib/lock/compat_mutex.h
@@ -58,6 +58,11 @@ void tor_mutex_init_nonrecursive(tor_mutex_t *m);
void tor_mutex_acquire(tor_mutex_t *m);
void tor_mutex_release(tor_mutex_t *m);
void tor_mutex_free_(tor_mutex_t *m);
+/**
+ * @copydoc tor_mutex_free_
+ *
+ * Additionally, set the pointer <b>m</b> to NULL.
+ **/
#define tor_mutex_free(m) FREE_AND_NULL(tor_mutex_t, tor_mutex_free_, (m))
void tor_mutex_uninit(tor_mutex_t *m);
diff --git a/src/lib/lock/compat_mutex_pthreads.c b/src/lib/lock/compat_mutex_pthreads.c
index f82ad9f0e..a7f5986ec 100644
--- a/src/lib/lock/compat_mutex_pthreads.c
+++ b/src/lib/lock/compat_mutex_pthreads.c
@@ -17,8 +17,14 @@
* "recursive" mutexes (i.e., once we can re-lock if we're already holding
* them.) */
static pthread_mutexattr_t attr_recursive;
+/**
+ * True iff <b>attr_recursive</b> has been initialized.
+ **/
static int attr_initialized = 0;
+/**
+ * Initialize the locking module, if it is not already initialized.
+ **/
void
tor_locking_init(void)
{
diff --git a/src/lib/memarea/memarea.h b/src/lib/memarea/memarea.h
index 9c23cf62e..dd0ed57fb 100644
--- a/src/lib/memarea/memarea.h
+++ b/src/lib/memarea/memarea.h
@@ -16,6 +16,9 @@ typedef struct memarea_t memarea_t;
memarea_t *memarea_new(void);
void memarea_drop_all_(memarea_t *area);
+/** @copydoc memarea_drop_all_
+ *
+ * Additionally, set <b>area</b> to NULL. */
#define memarea_drop_all(area) \
do { \
memarea_drop_all_(area); \
diff --git a/src/lib/pubsub/pubsub_build.h b/src/lib/pubsub/pubsub_build.h
index 5a0c5f5bd..13ec09c98 100644
--- a/src/lib/pubsub/pubsub_build.h
+++ b/src/lib/pubsub/pubsub_build.h
@@ -85,6 +85,11 @@ struct dispatch_t *pubsub_builder_finalize(pubsub_builder_t *,
**/
void pubsub_items_clear_bindings(pubsub_items_t *items);
+/**
+ * @copydoc pubsub_items_free_
+ *
+ * Additionally, set the pointer <b>cfg</b> to NULL.
+ **/
#define pubsub_items_free(cfg) \
FREE_AND_NULL(pubsub_items_t, pubsub_items_free_, (cfg))
void pubsub_items_free_(pubsub_items_t *cfg);
diff --git a/src/lib/pubsub/pubsub_check.c b/src/lib/pubsub/pubsub_check.c
index bf1196df2..38723e56e 100644
--- a/src/lib/pubsub/pubsub_check.c
+++ b/src/lib/pubsub/pubsub_check.c
@@ -9,7 +9,9 @@
* @brief Enforce various requirements on a pubsub_builder.
**/
+/** @{ */
#define PUBSUB_PRIVATE
+/** @} */
#include "lib/dispatch/dispatch_naming.h"
#include "lib/dispatch/msgtypes.h"
diff --git a/src/lib/pubsub/pubsub_macros.h b/src/lib/pubsub/pubsub_macros.h
index 357e59fd5..5c02fc354 100644
--- a/src/lib/pubsub/pubsub_macros.h
+++ b/src/lib/pubsub/pubsub_macros.h
@@ -163,7 +163,7 @@
* hookfn with the appropriate arguments.
*/
-/* Macro to declare common elements shared by DECLARE_MESSAGE and
+/** Macro to declare common elements shared by DECLARE_MESSAGE and
* DECLARE_MESSAGE_INT. Don't call this directly.
*
* Note that the "msg_arg_name" string constant is defined in each
@@ -288,7 +288,7 @@
( 0 ? (publish_fn__ ##messagename((msg_arg_type__##messagename)0), 1) \
: 1)
-/*
+/**
* This macro is for internal use. It backs DISPATCH_ADD_PUB*()
*/
#define DISPATCH_ADD_PUB_(connector, channel, messagename, flags) \
@@ -322,7 +322,7 @@
#define DISPATCH_ADD_PUB_EXCL(connector, channel, messagename) \
DISPATCH_ADD_PUB_(connector, channel, messagename, DISP_FLAG_EXCL)
-/*
+/**
* This macro is for internal use. It backs DISPATCH_ADD_SUB*()
*/
#define DISPATCH_ADD_SUB_(connector, channel, messagename, flags) \
@@ -334,7 +334,7 @@
(flags), \
__FILE__, \
__LINE__)
-/*
+/**
* Use a given connector and channel name to declare that this subsystem will
* receive a given message type.
*
diff --git a/src/lib/subsys/subsys.h b/src/lib/subsys/subsys.h
index 35a30680e..91abdb7d7 100644
--- a/src/lib/subsys/subsys.h
+++ b/src/lib/subsys/subsys.h
@@ -90,11 +90,19 @@ typedef struct subsys_fns_t {
} subsys_fns_t;
+/**
+ * Lowest allowed subsystem level.
+ **/
#define MIN_SUBSYS_LEVEL -100
+/**
+ * Highest allowed subsystem level.
+ **/
#define MAX_SUBSYS_LEVEL 100
-/* All tor "libraries" (in src/libs) should have a subsystem level equal to or
- * less than this value. */
+/**
+ * All tor "libraries" (in src/libs) should have a subsystem level equal to or
+ * less than this value.
+ */
#define SUBSYS_LEVEL_LIBS -10
#endif /* !defined(TOR_SUBSYS_T) */
diff --git a/src/lib/testsupport/testsupport.h b/src/lib/testsupport/testsupport.h
index 90b7c43b1..833515c32 100644
--- a/src/lib/testsupport/testsupport.h
+++ b/src/lib/testsupport/testsupport.h
@@ -15,17 +15,42 @@
#ifndef TOR_TESTSUPPORT_H
#define TOR_TESTSUPPORT_H
-#ifdef TOR_UNIT_TESTS
/** The "STATIC" macro marks a function or variable that is static when
* building Tor for production, but non-static when building the unit
- * tests. */
+ * tests.
+ *
+ * For example, a function declared as:
+ *
+ * STATIC int internal_function(void);
+ *
+ * should be only visible for the file on which it is declared, and in the
+ * unit tests.
+ */
+#ifdef TOR_UNIT_TESTS
#define STATIC
-#define EXTERN(type, name) extern type name;
#else /* !defined(TOR_UNIT_TESTS) */
#define STATIC static
-#define EXTERN(type, name)
#endif /* defined(TOR_UNIT_TESTS) */
+/** The "EXTERN" macro is used along with "STATIC" for variables declarations:
+ * it expands to an extern declaration when Tor building unit tests, and to
+ * nothing otherwise.
+ *
+ * For example, to declare a variable as visible only visible in one
+ * file and in the unit tests, you would put this in the header:
+ *
+ * EXTERN(int, local_variable)
+ *
+ * and this in the source:
+ *
+ * STATIC int local_variable;
+ */
+#ifdef TOR_UNIT_TESTS
+#define EXTERN(type, name) extern type name;
+#else
+#define EXTERN(type, name)
+#endif
+
/** Quick and dirty macros to implement test mocking.
*
* To use them, suppose that you have a function you'd like to mock
@@ -70,32 +95,42 @@
*
* @{ */
#ifdef TOR_UNIT_TESTS
+/** Declare a mocked function. For use in headers. */
#define MOCK_DECL(rv, funcname, arglist) \
rv funcname ##__real arglist; \
extern rv(*funcname) arglist
+/** Define the implementation of a mocked function. */
#define MOCK_IMPL(rv, funcname, arglist) \
rv(*funcname) arglist = funcname ##__real; \
rv funcname ##__real arglist
+/** As MOCK_DECL(), but allow attributes. */
#define MOCK_DECL_ATTR(rv, funcname, arglist, attr) \
rv funcname ##__real arglist attr; \
extern rv(*funcname) arglist
-#define MOCK_IMPL(rv, funcname, arglist) \
- rv(*funcname) arglist = funcname ##__real; \
- rv funcname ##__real arglist
+/**
+ * Replace <b>func</b> (a mockable function) with a replacement function.
+ *
+ * Only usable when Tor has been built for unit tests. */
#define MOCK(func, replacement) \
do { \
(func) = (replacement); \
} while (0)
+/** Replace <b>func</b> (a mockable function) with its original value.
+ *
+ * Only usable when Tor has been built for unit tests. */
#define UNMOCK(func) \
do { \
func = func ##__real; \
} while (0)
#else /* !defined(TOR_UNIT_TESTS) */
+/** Declare a mocked function. For use in headers. */
#define MOCK_DECL(rv, funcname, arglist) \
rv funcname arglist
-#define MOCK_DECL_ATTR(rv, funcname, arglist, attr) \
+/** As MOCK_DECL(), but allow */
+#define MOCK_DECL_ATTR(rv, funcname, arglist, attr) \
rv funcname arglist attr
-#define MOCK_IMPL(rv, funcname, arglist) \
+/** Define the implementation of a mocked function. */
+#define MOCK_IMPL(rv, funcname, arglist) \
rv funcname arglist
#endif /* defined(TOR_UNIT_TESTS) */
/** @} */
diff --git a/src/lib/version/git_revision.c b/src/lib/version/git_revision.c
index e87620a20..9ee49f0c3 100644
--- a/src/lib/version/git_revision.c
+++ b/src/lib/version/git_revision.c
@@ -23,6 +23,12 @@ const char tor_git_revision[] =
#endif
"";
+/**
+ * String appended to Tor bug messages describing the Tor version.
+ *
+ * It has the form "(on Tor 0.4.3.1-alpha)" or
+ * "(on Tor 0.4.3.1-alpha git-b994397f1af193f8)"
+ **/
const char tor_bug_suffix[] = " (on Tor " VERSION
#ifndef COCCI
#ifndef _MSC_VER
diff --git a/src/lib/version/version.c b/src/lib/version/version.c
index b2f25e97b..b08d566e1 100644
--- a/src/lib/version/version.c
+++ b/src/lib/version/version.c
@@ -24,6 +24,10 @@ static const char the_short_tor_version[] =
#endif
"";
+/**
+ * Longest possible version length. We make this a constant so that we
+ * can statically allocate the_tor_version.
+ **/
#define MAX_VERSION_LEN 128
/** The version of this Tor process, possibly including git version */
diff --git a/src/lib/wallclock/approx_time.c b/src/lib/wallclock/approx_time.c
index 77eeddaf5..c3cac8b9f 100644
--- a/src/lib/wallclock/approx_time.c
+++ b/src/lib/wallclock/approx_time.c
@@ -44,6 +44,9 @@ update_approx_time(time_t now)
}
#endif /* !defined(TIME_IS_FAST) */
+/**
+ * Initialize the "wallclock" subsystem by setting the current cached time.
+ **/
static int
subsys_wallclock_initialize(void)
{
@@ -51,6 +54,9 @@ subsys_wallclock_initialize(void)
return 0;
}
+/**
+ * Subsystem function table describing the "wallclock" subsystem.
+ **/
const subsys_fns_t sys_wallclock = {
.name = "wallclock",
.supported = true,
1
0