Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 5c2bad2

Browse files
committed
Bug 1551276 - Autodetect legacy encodings on unlabeled pages. r=emk
Differential Revision: https://phabricator.services.mozilla.com/D56362 --HG-- extra : moz-landing-system : lando
1 parent 71bbad4 commit 5c2bad2

157 files changed

Lines changed: 7027 additions & 2125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

browser/components/preferences/fonts.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* License, v. 2.0. If a copy of the MPL was not distributed with this
44
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
55

6+
/* import-globals-from ../../base/content/utilityOverlay.js */
67
/* import-globals-from ../../../toolkit/mozapps/preferences/fontbuilder.js */
78

89
// browser.display.languageList LOCK ALL when LOCKED
@@ -29,6 +30,10 @@ Preferences.addAll([
2930
{ id: "intl.charset.fallback.override", type: "string" },
3031
]);
3132

33+
document.getElementById("FallbackGroupbox").hidden = Services.prefs.getBoolPref(
34+
"intl.charset.detector.ng.enabled"
35+
);
36+
3237
var gFontsDialog = {
3338
_selectLanguageGroupPromise: Promise.resolve(),
3439

browser/components/preferences/fonts.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
</groupbox>
235235

236236
<!-- Text Encoding -->
237-
<groupbox>
237+
<groupbox id="FallbackGroupbox">
238238
<label><html:h2 data-l10n-id="fonts-languages-fallback-header"/></label>
239239
<description data-l10n-id="fonts-languages-fallback-desc"/>
240240
<hbox align="center">

docshell/base/nsDocShell.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,7 +1290,8 @@ nsDocShell::GatherCharsetMenuTelemetry() {
12901290
Telemetry::LABELS_ENCODING_OVERRIDE_SITUATION::RemoteNonTld);
12911291
}
12921292
break;
1293-
case kCharsetFromAutoDetection:
1293+
case kCharsetFromInitialAutoDetection:
1294+
case kCharsetFromFinalAutoDetection:
12941295
// Changing charset on unlabeled doc where chardet fired
12951296
if (isFileURL) {
12961297
Telemetry::AccumulateCategorical(
@@ -1921,7 +1922,8 @@ nsDocShell::GetCharsetAutodetected(bool* aCharsetAutodetected) {
19211922
}
19221923
int32_t source = doc->GetDocumentCharacterSetSource();
19231924

1924-
if (source == kCharsetFromAutoDetection ||
1925+
if (source == kCharsetFromInitialAutoDetection ||
1926+
source == kCharsetFromFinalAutoDetection ||
19251927
source == kCharsetFromUserForcedAutoDetection) {
19261928
*aCharsetAutodetected = true;
19271929
}

docshell/test/browser/browser_bug1543077-1.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ function test() {
1010

1111
function afterOpen() {
1212
is(
13-
content.document.documentElement.textContent.indexOf("\u00A4"),
13+
content.document.documentElement.textContent.indexOf("\u0434"),
1414
131,
15-
"Parent doc should be windows-1252 initially"
15+
"Parent doc should be IBM866 initially"
1616
);
1717

1818
is(
19-
content.frames[0].document.documentElement.textContent.indexOf("\u00A4"),
19+
content.frames[0].document.documentElement.textContent.indexOf("\u0434"),
2020
87,
21-
"Child doc should be windows-1252 initially"
21+
"Child doc should be IBM866 initially"
2222
);
2323
}
2424

docshell/test/browser/browser_bug1543077-2.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ function test() {
1010

1111
function afterOpen() {
1212
is(
13-
content.document.documentElement.textContent.indexOf("\u201A"),
13+
content.document.documentElement.textContent.indexOf("\u0412"),
1414
134,
15-
"Parent doc should be windows-1252 initially"
15+
"Parent doc should be IBM866 initially"
1616
);
1717

1818
is(
19-
content.frames[0].document.documentElement.textContent.indexOf("\u201A"),
19+
content.frames[0].document.documentElement.textContent.indexOf("\u0412"),
2020
90,
21-
"Child doc should be windows-1252 initially"
21+
"Child doc should be IBM866 initially"
2222
);
2323
}
2424

docshell/test/browser/browser_bug1543077-3.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ function test() {
1010

1111
function afterOpen() {
1212
is(
13-
content.document.documentElement.textContent.indexOf("\u001B"),
13+
content.document.documentElement.textContent.indexOf("\u3042"),
1414
136,
15-
"Parent doc should be windows-1252 initially"
15+
"Parent doc should be ISO-2022-JP initially"
1616
);
1717

1818
is(
19-
content.frames[0].document.documentElement.textContent.indexOf("\u001B"),
19+
content.frames[0].document.documentElement.textContent.indexOf("\u3042"),
2020
92,
21-
"Child doc should be windows-1252 initially"
21+
"Child doc should be ISO-2022-JP initially"
2222
);
2323
}
2424

docshell/test/browser/browser_bug1543077-4.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ function test() {
1010

1111
function afterOpen() {
1212
is(
13-
content.document.documentElement.textContent.indexOf("\u00A4"),
13+
content.document.documentElement.textContent.indexOf("\u0434"),
1414
131,
15-
"Parent doc should be windows-1252 initially"
15+
"Parent doc should be IBM866 initially"
1616
);
1717

1818
is(
19-
content.frames[0].document.documentElement.textContent.indexOf("\u201A"),
19+
content.frames[0].document.documentElement.textContent.indexOf("\u0412"),
2020
90,
21-
"Child doc should be windows-1252 initially"
21+
"Child doc should be IBM866 initially"
2222
);
2323
}
2424

dom/base/nsContentUtils.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@
150150
#include "nsIAsyncVerifyRedirectCallback.h"
151151
#include "nsICategoryManager.h"
152152
#include "nsIChannelEventSink.h"
153-
#include "nsICharsetDetectionObserver.h"
154153
#include "nsIConsoleService.h"
155154
#include "nsIContent.h"
156155
#include "nsIContentInlines.h"

dom/html/nsHTMLDocument.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ void nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell,
288288
return;
289289
}
290290
if (kCharsetFromParentForced == parentSource ||
291-
kCharsetFromUserForced == parentSource) {
291+
kCharsetFromUserForced == parentSource ||
292+
kCharsetFromUserForcedAutoDetection == parentSource) {
292293
if (WillIgnoreCharsetOverride() ||
293294
!IsAsciiCompatible(aEncoding) || // if channel said UTF-16
294295
!IsAsciiCompatible(parentCharset)) {

0 commit comments

Comments
 (0)