| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. | 7 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. |
| 8 * (http://www.torchmobile.com/) | 8 * (http://www.torchmobile.com/) |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "wtf/CryptographicallyRandomNumber.h" | 28 #include "wtf/CryptographicallyRandomNumber.h" |
| 29 #include "wtf/HexNumber.h" | 29 #include "wtf/HexNumber.h" |
| 30 #include "wtf/text/CString.h" | 30 #include "wtf/text/CString.h" |
| 31 #include "wtf/text/TextEncoding.h" | 31 #include "wtf/text/TextEncoding.h" |
| 32 #include <limits> | 32 #include <limits> |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 // Helper functions | 36 // Helper functions |
| 37 static inline void append(Vector<char>& buffer, char string) { | 37 static inline void append(Vector<char>& buffer, char string) { |
| 38 buffer.append(string); | 38 buffer.push_back(string); |
| 39 } | 39 } |
| 40 | 40 |
| 41 static inline void append(Vector<char>& buffer, const char* string) { | 41 static inline void append(Vector<char>& buffer, const char* string) { |
| 42 buffer.append(string, strlen(string)); | 42 buffer.append(string, strlen(string)); |
| 43 } | 43 } |
| 44 | 44 |
| 45 static inline void append(Vector<char>& buffer, const CString& string) { | 45 static inline void append(Vector<char>& buffer, const CString& string) { |
| 46 buffer.append(string.data(), string.length()); | 46 buffer.append(string.data(), string.length()); |
| 47 } | 47 } |
| 48 | 48 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42}; | 117 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42}; |
| 118 | 118 |
| 119 // Start with an informative prefix. | 119 // Start with an informative prefix. |
| 120 append(boundary, "----WebKitFormBoundary"); | 120 append(boundary, "----WebKitFormBoundary"); |
| 121 | 121 |
| 122 // Append 16 random 7bit ascii AlphaNumeric characters. | 122 // Append 16 random 7bit ascii AlphaNumeric characters. |
| 123 Vector<char> randomBytes; | 123 Vector<char> randomBytes; |
| 124 | 124 |
| 125 for (unsigned i = 0; i < 4; ++i) { | 125 for (unsigned i = 0; i < 4; ++i) { |
| 126 uint32_t randomness = cryptographicallyRandomNumber(); | 126 uint32_t randomness = cryptographicallyRandomNumber(); |
| 127 randomBytes.append(alphaNumericEncodingMap[(randomness >> 24) & 0x3F]); | 127 randomBytes.push_back(alphaNumericEncodingMap[(randomness >> 24) & 0x3F]); |
| 128 randomBytes.append(alphaNumericEncodingMap[(randomness >> 16) & 0x3F]); | 128 randomBytes.push_back(alphaNumericEncodingMap[(randomness >> 16) & 0x3F]); |
| 129 randomBytes.append(alphaNumericEncodingMap[(randomness >> 8) & 0x3F]); | 129 randomBytes.push_back(alphaNumericEncodingMap[(randomness >> 8) & 0x3F]); |
| 130 randomBytes.append(alphaNumericEncodingMap[randomness & 0x3F]); | 130 randomBytes.push_back(alphaNumericEncodingMap[randomness & 0x3F]); |
| 131 } | 131 } |
| 132 | 132 |
| 133 boundary.appendVector(randomBytes); | 133 boundary.appendVector(randomBytes); |
| 134 boundary.append( | 134 boundary.push_back( |
| 135 0); // Add a 0 at the end so we can use this as a C-style string. | 135 0); // Add a 0 at the end so we can use this as a C-style string. |
| 136 return boundary; | 136 return boundary; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void FormDataEncoder::beginMultiPartHeader(Vector<char>& buffer, | 139 void FormDataEncoder::beginMultiPartHeader(Vector<char>& buffer, |
| 140 const CString& boundary, | 140 const CString& boundary, |
| 141 const CString& name) { | 141 const CString& name) { |
| 142 addBoundaryToMultiPartHeader(buffer, boundary); | 142 addBoundaryToMultiPartHeader(buffer, boundary); |
| 143 | 143 |
| 144 // FIXME: This loses data irreversibly if the input name includes characters | 144 // FIXME: This loses data irreversibly if the input name includes characters |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 appendPercentEncoded(buffer, c); | 228 appendPercentEncoded(buffer, c); |
| 229 } | 229 } |
| 230 } else { | 230 } else { |
| 231 appendPercentEncoded(buffer, c); | 231 appendPercentEncoded(buffer, c); |
| 232 } | 232 } |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace blink | 237 } // namespace blink |
| OLD | NEW |