Index: third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp |
diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp |
index 7c483538ae2e3bf7f81ee0808da03883f4b568d9..f44c29f8535cea1bd957ba53a00b121a3b34f15d 100644 |
--- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp |
+++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp |
@@ -112,7 +112,7 @@ const WTF::TextEncoding& TextResourceDecoder::defaultEncoding(ContentType conten |
return specifiedDefaultEncoding; |
} |
-TextResourceDecoder::TextResourceDecoder(const String& mimeType, const WTF::TextEncoding& specifiedDefaultEncoding, bool usesEncodingDetector) |
+TextResourceDecoder::TextResourceDecoder(const String& mimeType, const WTF::TextEncoding& specifiedDefaultEncoding, bool usesEncodingDetector, BOMCheckOptions bomCheckOptions) |
: m_contentType(determineContentType(mimeType)) |
, m_encoding(defaultEncoding(m_contentType, specifiedDefaultEncoding)) |
, m_source(DefaultEncoding) |
@@ -124,6 +124,7 @@ TextResourceDecoder::TextResourceDecoder(const String& mimeType, const WTF::Text |
, m_useLenientXMLDecoding(false) |
, m_sawError(false) |
, m_usesEncodingDetector(usesEncodingDetector) |
+ , m_bomCheckOptions(bomCheckOptions) |
{ |
} |
@@ -210,7 +211,7 @@ size_t TextResourceDecoder::checkForBOM(const char* data, size_t len) |
unsigned char c4 = buf2Len ? (--buf2Len, *buf2++) : 0; |
// Check for the BOM. |
- if (c1 == 0xFF && c2 == 0xFE) { |
+ if (m_bomCheckOptions == CheckForAllBOM && c1 == 0xFF && c2 == 0xFE) { |
if (c3 || c4) { |
setEncoding(UTF16LittleEndianEncoding(), AutoDetectedEncoding); |
lengthOfBOM = 2; |
@@ -221,10 +222,10 @@ size_t TextResourceDecoder::checkForBOM(const char* data, size_t len) |
} else if (c1 == 0xEF && c2 == 0xBB && c3 == 0xBF) { |
setEncoding(UTF8Encoding(), AutoDetectedEncoding); |
lengthOfBOM = 3; |
- } else if (c1 == 0xFE && c2 == 0xFF) { |
+ } else if (m_bomCheckOptions == CheckForAllBOM && c1 == 0xFE && c2 == 0xFF) { |
setEncoding(UTF16BigEndianEncoding(), AutoDetectedEncoding); |
lengthOfBOM = 2; |
- } else if (!c1 && !c2 && c3 == 0xFE && c4 == 0xFF) { |
+ } else if (m_bomCheckOptions == CheckForAllBOM && !c1 && !c2 && c3 == 0xFE && c4 == 0xFF) { |
setEncoding(UTF32BigEndianEncoding(), AutoDetectedEncoding); |
lengthOfBOM = 4; |
} |