OLD | NEW |
---|---|
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 Loading... | |
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()); | |
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
| |
423 } | |
424 | |
403 } // namespace blink | 425 } // namespace blink |
OLD | NEW |