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

Unified Diff: third_party/WebKit/Source/platform/mhtml/MHTMLParser.cpp

Issue 1441553002: Generating CIDs in Blink during MHTML serialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mhtml-per-frame-page-serializer-only
Patch Set: Replace list Replaced initializer lists with array initialization. Created 5 years 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/platform/mhtml/MHTMLParser.cpp
diff --git a/third_party/WebKit/Source/platform/mhtml/MHTMLParser.cpp b/third_party/WebKit/Source/platform/mhtml/MHTMLParser.cpp
index cc67350bc8c7374af3a0676d2470fe7922747496..45846986e945786ee9c398bec4ab24c3b5d3be7f 100644
--- a/third_party/WebKit/Source/platform/mhtml/MHTMLParser.cpp
+++ b/third_party/WebKit/Source/platform/mhtml/MHTMLParser.cpp
@@ -400,4 +400,26 @@ ArchiveResource* MHTMLParser::subResourceAt(size_t index) const
return m_resources[index].get();
}
+// static
+KURL MHTMLParser::convertContentIDToURI(const String& contentID)
+{
+ // This function is based primarily on an example from rfc2557 in section
+ // 9.5, but also based on more normative parts of specs like:
+ // - rfc2557 - MHTML - section 8.3 - "Use of the Content-ID header and CID URLs"
+ // - rfc1738 - URL - section 4 (reserved scheme names; includes "cid")
+ // - rfc2387 - multipart/related - section 3.4 - "Syntax" (cid := msg-id)
+ // - rfc0822 - msg-id = "<" addr-spec ">"; addr-spec = local-part "@" domain
+
+ if (contentID.length() <= 2)
+ return KURL();
+
+ if (!contentID.startsWith('<') || !contentID.endsWith('>'))
+ return KURL();
+
+ StringBuilder uriBuilder;
+ uriBuilder.append("cid:");
+ uriBuilder.append(contentID, 1, contentID.length() - 2);
+ return KURL(KURL(), uriBuilder.toString());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/mhtml/MHTMLParser.h ('k') | third_party/WebKit/Source/web/WebPageSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698