| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "wtf/DateMath.h" | 44 #include "wtf/DateMath.h" |
| 45 #include "wtf/text/Base64.h" | 45 #include "wtf/text/Base64.h" |
| 46 #include "wtf/text/StringBuilder.h" | 46 #include "wtf/text/StringBuilder.h" |
| 47 | 47 |
| 48 namespace blink { | 48 namespace blink { |
| 49 | 49 |
| 50 const char* const quotedPrintable = "quoted-printable"; | 50 const char* const quotedPrintable = "quoted-printable"; |
| 51 const char* const base64 = "base64"; | 51 const char* const base64 = "base64"; |
| 52 const char* const binary = "binary"; | 52 const char* const binary = "binary"; |
| 53 | 53 |
| 54 String MHTMLArchive::generateMHTMLBoundary() | |
| 55 { | |
| 56 // Trying to generate random boundaries similar to IE/UnMHT | |
| 57 // (ex: ----=_NextPart_000_001B_01CC157B.96F808A0). | |
| 58 const size_t randomValuesLength = 10; | |
| 59 char randomValues[randomValuesLength]; | |
| 60 cryptographicallyRandomValues(&randomValues, randomValuesLength); | |
| 61 StringBuilder stringBuilder; | |
| 62 stringBuilder.appendLiteral("----=_NextPart_000_"); | |
| 63 for (size_t i = 0; i < randomValuesLength; ++i) { | |
| 64 if (i == 2) | |
| 65 stringBuilder.append('_'); | |
| 66 else if (i == 6) | |
| 67 stringBuilder.append('.'); | |
| 68 stringBuilder.append(lowerNibbleToASCIIHexDigit(randomValues[i])); | |
| 69 stringBuilder.append(upperNibbleToASCIIHexDigit(randomValues[i])); | |
| 70 } | |
| 71 return stringBuilder.toString(); | |
| 72 } | |
| 73 | |
| 74 static String replaceNonPrintableCharacters(const String& text) | 54 static String replaceNonPrintableCharacters(const String& text) |
| 75 { | 55 { |
| 76 StringBuilder stringBuilder; | 56 StringBuilder stringBuilder; |
| 77 for (size_t i = 0; i < text.length(); ++i) { | 57 for (size_t i = 0; i < text.length(); ++i) { |
| 78 if (isASCIIPrintable(text[i])) | 58 if (isASCIIPrintable(text[i])) |
| 79 stringBuilder.append(text[i]); | 59 stringBuilder.append(text[i]); |
| 80 else | 60 else |
| 81 stringBuilder.append('?'); | 61 stringBuilder.append('?'); |
| 82 } | 62 } |
| 83 return stringBuilder.toString(); | 63 return stringBuilder.toString(); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 265 } |
| 286 | 266 |
| 287 DEFINE_TRACE(MHTMLArchive) | 267 DEFINE_TRACE(MHTMLArchive) |
| 288 { | 268 { |
| 289 visitor->trace(m_mainResource); | 269 visitor->trace(m_mainResource); |
| 290 visitor->trace(m_subresources); | 270 visitor->trace(m_subresources); |
| 291 visitor->trace(m_subframeArchives); | 271 visitor->trace(m_subframeArchives); |
| 292 } | 272 } |
| 293 | 273 |
| 294 } | 274 } |
| OLD | NEW |