Chromium Code Reviews| 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()); |
|
dcheng
2015/12/01 04:19:31
Maybe use ParsedURLString? It's guaranteed that ur
Łukasz Anforowicz
2015/12/01 18:45:14
I almost made the change you've suggested, but sta
|
| +} |
| + |
| } // namespace blink |