OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/browser/api/web_request/form_data_parser.h" | 5 #include "extensions/browser/api/web_request/form_data_parser.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 enum ParserChoice {URL_ENCODED, MULTIPART, ERROR_CHOICE}; | 308 enum ParserChoice {URL_ENCODED, MULTIPART, ERROR_CHOICE}; |
309 ParserChoice choice = ERROR_CHOICE; | 309 ParserChoice choice = ERROR_CHOICE; |
310 std::string boundary; | 310 std::string boundary; |
311 | 311 |
312 if (content_type_header == NULL) { | 312 if (content_type_header == NULL) { |
313 choice = URL_ENCODED; | 313 choice = URL_ENCODED; |
314 } else { | 314 } else { |
315 const std::string content_type( | 315 const std::string content_type( |
316 content_type_header->substr(0, content_type_header->find(';'))); | 316 content_type_header->substr(0, content_type_header->find(';'))); |
317 | 317 |
318 if (base::strcasecmp( | 318 if (base::EqualsCaseInsensitiveASCII(content_type, |
319 content_type.c_str(), "application/x-www-form-urlencoded") == 0) { | 319 "application/x-www-form-urlencoded")) { |
320 choice = URL_ENCODED; | 320 choice = URL_ENCODED; |
321 } else if (base::strcasecmp( | 321 } else if (base::EqualsCaseInsensitiveASCII(content_type, |
322 content_type.c_str(), "multipart/form-data") == 0) { | 322 "multipart/form-data")) { |
323 static const char kBoundaryString[] = "boundary="; | 323 static const char kBoundaryString[] = "boundary="; |
324 size_t offset = content_type_header->find(kBoundaryString); | 324 size_t offset = content_type_header->find(kBoundaryString); |
325 if (offset == std::string::npos) { | 325 if (offset == std::string::npos) { |
326 // Malformed header. | 326 // Malformed header. |
327 return scoped_ptr<FormDataParser>(); | 327 return scoped_ptr<FormDataParser>(); |
328 } | 328 } |
329 offset += sizeof(kBoundaryString) - 1; | 329 offset += sizeof(kBoundaryString) - 1; |
330 boundary = content_type_header->substr( | 330 boundary = content_type_header->substr( |
331 offset, content_type_header->find(';', offset)); | 331 offset, content_type_header->find(';', offset)); |
332 if (!boundary.empty()) | 332 if (!boundary.empty()) |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 if (value_pattern().Match(header, | 587 if (value_pattern().Match(header, |
588 kContentDispositionLength, header.size(), | 588 kContentDispositionLength, header.size(), |
589 RE2::UNANCHORED, groups, 2)) { | 589 RE2::UNANCHORED, groups, 2)) { |
590 value->set(groups[1].data(), groups[1].size()); | 590 value->set(groups[1].data(), groups[1].size()); |
591 *value_assigned = true; | 591 *value_assigned = true; |
592 } | 592 } |
593 return true; | 593 return true; |
594 } | 594 } |
595 | 595 |
596 } // namespace extensions | 596 } // namespace extensions |
OLD | NEW |