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

Unified Diff: third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h

Issue 1470893002: [Fetch] Always use utf-8 for decoding in text() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add fixes. Created 5 years, 1 month 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
Index: third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
index 2539cc8a68577c5e20da2b757637e3e510931e27..8d894b5bf81d49abb83a062d03559d16457ae676 100644
--- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
+++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
@@ -46,9 +46,18 @@ public:
EncodingFromParentFrame
};
- static PassOwnPtr<TextResourceDecoder> create(const String& mimeType, const WTF::TextEncoding& defaultEncoding = WTF::TextEncoding(), bool usesEncodingDetector = false)
+ enum BOMCheckOptions {
+ CheckForAllBOM,
+ // create("text/plain", UTF8Encoding(), false, CheckForOnlyUTF8BOM)
+ // always uses UTF8Encoding() and omits utf-8 BOM, and thus
+ // corresponds to utf-8 decode in Encoding spec:
+ // https://encoding.spec.whatwg.org/#utf-8-decode
+ CheckForOnlyUTF8BOM
+ };
+
+ static PassOwnPtr<TextResourceDecoder> create(const String& mimeType, const WTF::TextEncoding& defaultEncoding = WTF::TextEncoding(), bool usesEncodingDetector = false, BOMCheckOptions bomCheckOptions = CheckForAllBOM)
{
- return adoptPtr(new TextResourceDecoder(mimeType, defaultEncoding, usesEncodingDetector));
+ return adoptPtr(new TextResourceDecoder(mimeType, defaultEncoding, usesEncodingDetector, bomCheckOptions));
}
~TextResourceDecoder();
@@ -73,7 +82,7 @@ public:
size_t checkForBOM(const char*, size_t);
private:
- TextResourceDecoder(const String& mimeType, const WTF::TextEncoding& defaultEncoding, bool usesEncodingDetector);
+ TextResourceDecoder(const String& mimeType, const WTF::TextEncoding& defaultEncoding, bool usesEncodingDetector, BOMCheckOptions);
enum ContentType { PlainTextContent, HTMLContent, XMLContent, CSSContent }; // PlainText only checks for BOM.
static ContentType determineContentType(const String& mimeType);
@@ -97,6 +106,7 @@ private:
bool m_useLenientXMLDecoding; // Don't stop on XML decoding errors.
bool m_sawError;
bool m_usesEncodingDetector;
+ BOMCheckOptions m_bomCheckOptions;
OwnPtr<HTMLMetaCharsetParser> m_charsetParser;
};

Powered by Google App Engine
This is Rietveld 408576698