Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp

Issue 2803563004: Avoid using language hint in encoding detection (Closed)
Patch Set: fix bug Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp
diff --git a/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp b/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp
index d32e81d2f1b970a90f46d191efb891050c237923..7bf6e0c513dbe2997361db54ac1941d70cf7e21d 100644
--- a/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp
+++ b/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp
@@ -43,8 +43,12 @@ bool detectTextEncoding(const char* data,
const char* hintUserLanguage,
WTF::TextEncoding* detectedEncoding) {
*detectedEncoding = WTF::TextEncoding();
- Language language;
- LanguageFromCode(hintUserLanguage, &language);
+ // In general, do not use language hint. This helps get more
+ // deterministic encoding detection results across devices. Note that local
+ // file resources can still benefit from the hint.
+ Language language = UNKNOWN_LANGUAGE;
+ if (hintUrl.protocol() == "file")
+ LanguageFromCode(hintUserLanguage, &language);
int consumedBytes;
bool isReliable;
Encoding encoding = CompactEncDet::DetectEncoding(
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/text/TextEncodingDetectorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698