| 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 abda74b2b62b0e43cb7d1f4395e99bd359ce5ec6..a2674dbf065849d21e84f1831deea4144ad1d991 100644
|
| --- a/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp
|
| +++ b/third_party/WebKit/Source/platform/text/TextEncodingDetector.cpp
|
| @@ -46,14 +46,26 @@ bool detectTextEncoding(const char* data, size_t length,
|
| EncodingNameAliasToEncoding(hintEncodingName),
|
| UNKNOWN_LANGUAGE,
|
| CompactEncDet::WEB_CORPUS,
|
| - false, // Include 7-bit encodings
|
| + false, // Include 7-bit encodings to detect ISO-2022-JP
|
| &consumedBytes,
|
| &isReliable);
|
| - if (encoding != UNKNOWN_ENCODING) {
|
| - *detectedEncoding = WTF::TextEncoding(MimeEncodingName(encoding));
|
| - return true;
|
| + if (encoding == UNKNOWN_ENCODING)
|
| + return false;
|
| +
|
| + // 7-bit encodings (except ISO-2022-JP) are not supported in WHATWG encoding
|
| + // standard. Mark them as ASCII to keep the raw bytes intact.
|
| + switch (encoding) {
|
| + case HZ_GB_2312:
|
| + case ISO_2022_KR:
|
| + case ISO_2022_CN:
|
| + case UTF7:
|
| + encoding = ASCII_7BIT;
|
| + break;
|
| + default:
|
| + break;
|
| }
|
| - return false;
|
| + *detectedEncoding = WTF::TextEncoding(MimeEncodingName(encoding));
|
| + return true;
|
| }
|
|
|
| } // namespace blink
|
|
|