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

Commit 69ad08c

Browse files
committed
Bug 1071816 - Support loading unlabeled/BOMless UTF-8 text/html and text/plain files from file: URLs. r=emk.
1 parent 196354f commit 69ad08c

21 files changed

Lines changed: 1466 additions & 115 deletions

dom/encoding/FallbackEncoding.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ NS_IMPL_ISUPPORTS(FallbackEncoding, nsIObserver)
5555

5656
StaticRefPtr<FallbackEncoding> FallbackEncoding::sInstance;
5757
bool FallbackEncoding::sGuessFallbackFromTopLevelDomain = true;
58-
bool FallbackEncoding::sFallbackToUTF8ForFile = false;
5958

6059
FallbackEncoding::FallbackEncoding() : mFallback(nullptr) {
6160
MOZ_ASSERT(!FallbackEncoding::sInstance, "Singleton already exists.");
@@ -141,8 +140,6 @@ void FallbackEncoding::Initialize() {
141140
"intl.charset.fallback.override");
142141
Preferences::AddBoolVarCache(&sGuessFallbackFromTopLevelDomain,
143142
"intl.charset.fallback.tld");
144-
Preferences::AddBoolVarCache(&sFallbackToUTF8ForFile,
145-
"intl.charset.fallback.utf8_for_file");
146143

147144
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
148145
if (obs) {

dom/encoding/FallbackEncoding.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ class FallbackEncoding : public nsIObserver, nsSupportsWeakReference {
2727
*/
2828
static bool sGuessFallbackFromTopLevelDomain;
2929

30-
/**
31-
* Whether UTF-8 should be used for file URLs.
32-
*/
33-
static bool sFallbackToUTF8ForFile;
34-
3530
/**
3631
* Gets the locale-dependent fallback encoding for legacy HTML and plain
3732
* text content.

dom/html/nsHTMLDocument.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,6 @@ void nsHTMLDocument::TryFallback(int32_t& aCharsetSource,
438438
if (kCharsetFromFallback <= aCharsetSource) return;
439439

440440
aCharsetSource = kCharsetFromFallback;
441-
bool isFile = false;
442-
if (FallbackEncoding::sFallbackToUTF8ForFile && mDocumentURI &&
443-
NS_SUCCEEDED(mDocumentURI->SchemeIs("file", &isFile)) && isFile) {
444-
aEncoding = UTF_8_ENCODING;
445-
return;
446-
}
447441
aEncoding = FallbackEncoding::FromLocale();
448442
}
449443

dom/html/nsHTMLDocument.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ class nsHTMLDocument : public nsDocument, public nsIHTMLDocument {
282282
void TryParentCharset(nsIDocShell* aDocShell, int32_t& charsetSource,
283283
NotNull<const Encoding*>& aEncoding);
284284
void TryTLD(int32_t& aCharsetSource, NotNull<const Encoding*>& aCharset);
285-
void TryFallback(int32_t& aCharsetSource,
286-
NotNull<const Encoding*>& aEncoding);
285+
static void TryFallback(int32_t& aCharsetSource,
286+
NotNull<const Encoding*>& aEncoding);
287287

288288
// Override so we can munge the charset on our wyciwyg channel as needed.
289289
virtual void SetDocumentCharacterSet(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>UTF-8</title>
5+
</head>
6+
<body>
7+
§
8+
</body>
9+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>windows-1252</title>
5+
</head>
6+
<body>
7+
§
8+
</body>
9+
</html>

0 commit comments

Comments
 (0)