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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 size_t MHTMLParser::subResourceCount() const 393 size_t MHTMLParser::subResourceCount() const
394 { 394 {
395 return m_resources.size(); 395 return m_resources.size();
396 } 396 }
397 397
398 ArchiveResource* MHTMLParser::subResourceAt(size_t index) const 398 ArchiveResource* MHTMLParser::subResourceAt(size_t index) const
399 { 399 {
400 return m_resources[index].get(); 400 return m_resources[index].get();
401 } 401 }
402 402
403 // static
404 KURL MHTMLParser::convertContentIDToURI(const String& contentID)
405 {
406 // This function is based primarily on an example from rfc2557 in section
407 // 9.5, but also based on more normative parts of specs like:
408 // - rfc2557 - MHTML - section 8.3 - "Use of the Content-ID header and CID U RLs"
409 // - rfc1738 - URL - section 4 (reserved scheme names; includes "cid")
410 // - rfc2387 - multipart/related - section 3.4 - "Syntax" (cid := msg-id)
411 // - rfc0822 - msg-id = "<" addr-spec ">"; addr-spec = local-part "@" domain
412
413 if (contentID.length() <= 2)
414 return KURL();
415
416 if (!contentID.startsWith('<') || !contentID.endsWith('>'))
417 return KURL();
418
419 StringBuilder uriBuilder;
420 uriBuilder.append("cid:");
421 uriBuilder.append(contentID, 1, contentID.length() - 2);
422 return KURL(KURL(), uriBuilder.toString());
423 }
424
403 } // namespace blink 425 } // namespace blink
OLDNEW
« 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