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

Unified Diff: Source/core/loader/archive/MHTMLParser.cpp

Issue 23464015: Default to binary encoding when loading MHTML files. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added layout test Created 7 years, 3 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 | « LayoutTests/mhtml/content_transfer_encoding_none-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/archive/MHTMLParser.cpp
diff --git a/Source/core/loader/archive/MHTMLParser.cpp b/Source/core/loader/archive/MHTMLParser.cpp
index 1134592743a6b85ad0018491e6c6ebbd1fe8cadb..6bab361df34085207f256f4d41ab93f0a24cc831 100644
--- a/Source/core/loader/archive/MHTMLParser.cpp
+++ b/Source/core/loader/archive/MHTMLParser.cpp
@@ -139,10 +139,15 @@ PassRefPtr<ArchiveResource> MHTMLParser::parseNextPart(const MIMEHeader& mimeHea
{
ASSERT(endOfPartBoundary.isEmpty() == endOfDocumentBoundary.isEmpty());
+ // If no content transfer encoding is specified, default to binary encoding.
+ MIMEHeader::Encoding contentTransferEncoding = mimeHeader.contentTransferEncoding();
+ if (contentTransferEncoding == MIMEHeader::Unknown)
+ contentTransferEncoding = MIMEHeader::Binary;
+
RefPtr<SharedBuffer> content = SharedBuffer::create();
const bool checkBoundary = !endOfPartBoundary.isEmpty();
bool endOfPartReached = false;
- if (mimeHeader.contentTransferEncoding() == MIMEHeader::Binary) {
+ if (contentTransferEncoding == MIMEHeader::Binary) {
if (!checkBoundary) {
LOG_ERROR("Binary contents requires end of part");
return 0;
@@ -180,7 +185,7 @@ PassRefPtr<ArchiveResource> MHTMLParser::parseNextPart(const MIMEHeader& mimeHea
}
// Note that we use line.utf8() and not line.ascii() as ascii turns special characters (such as tab, line-feed...) into '?'.
content->append(line.utf8().data(), line.length());
- if (mimeHeader.contentTransferEncoding() == MIMEHeader::QuotedPrintable) {
+ if (contentTransferEncoding == MIMEHeader::QuotedPrintable) {
// The line reader removes the \r\n, but we need them for the content in this case as the QuotedPrintable decoder expects CR-LF terminated lines.
content->append("\r\n", 2);
}
@@ -192,7 +197,7 @@ PassRefPtr<ArchiveResource> MHTMLParser::parseNextPart(const MIMEHeader& mimeHea
}
Vector<char> data;
- switch (mimeHeader.contentTransferEncoding()) {
+ switch (contentTransferEncoding) {
case MIMEHeader::Base64:
if (!base64Decode(content->data(), content->size(), data)) {
LOG_ERROR("Invalid base64 content for MHTML part.");
« no previous file with comments | « LayoutTests/mhtml/content_transfer_encoding_none-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698