| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 // nonalphanumeric characters. See | 39 // nonalphanumeric characters. See |
| 40 // blink/Source/platform/network/FormDataBuilder.cpp | 40 // blink/Source/platform/network/FormDataBuilder.cpp |
| 41 // blink::FormDataBuilder::generateUniqueBoundaryString(). | 41 // blink::FormDataBuilder::generateUniqueBoundaryString(). |
| 42 // | 42 // |
| 43 // This implementation produces a 56-character string with over 190 bits of | 43 // This implementation produces a 56-character string with over 190 bits of |
| 44 // randomness (62^32 > 2^190). | 44 // randomness (62^32 > 2^190). |
| 45 std::string boundary_string = "---MultipartBoundary-"; | 45 std::string boundary_string = "---MultipartBoundary-"; |
| 46 for (int index = 0; index < 32; ++index) { | 46 for (int index = 0; index < 32; ++index) { |
| 47 const char kCharacters[] = | 47 const char kCharacters[] = |
| 48 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | 48 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
| 49 int random_value = base::RandInt(0, strlen(kCharacters) - 1); | 49 int random_value = |
| 50 base::RandInt(0, static_cast<int>(strlen(kCharacters)) - 1); |
| 50 boundary_string += kCharacters[random_value]; | 51 boundary_string += kCharacters[random_value]; |
| 51 } | 52 } |
| 52 boundary_string += "---"; | 53 boundary_string += "---"; |
| 53 return boundary_string; | 54 return boundary_string; |
| 54 } | 55 } |
| 55 | 56 |
| 56 // Escapes the specified name to be suitable for the name field of a | 57 // Escapes the specified name to be suitable for the name field of a |
| 57 // form-data part. | 58 // form-data part. |
| 58 std::string EncodeMIMEField(const std::string& name) { | 59 std::string EncodeMIMEField(const std::string& name) { |
| 59 // RFC 2388 §3 says to encode non-ASCII field names according to RFC 2047, but | 60 // RFC 2388 §3 says to encode non-ASCII field names according to RFC 2047, but |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 auto data_it = form_data_.find(key); | 190 auto data_it = form_data_.find(key); |
| 190 if (data_it != form_data_.end()) | 191 if (data_it != form_data_.end()) |
| 191 form_data_.erase(data_it); | 192 form_data_.erase(data_it); |
| 192 | 193 |
| 193 auto file_it = file_attachments_.find(key); | 194 auto file_it = file_attachments_.find(key); |
| 194 if (file_it != file_attachments_.end()) | 195 if (file_it != file_attachments_.end()) |
| 195 file_attachments_.erase(file_it); | 196 file_attachments_.erase(file_it); |
| 196 } | 197 } |
| 197 | 198 |
| 198 } // namespace crashpad | 199 } // namespace crashpad |
| OLD | NEW |