| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 source_.remove_prefix(1); // Remove the leading '&'. | 390 source_.remove_prefix(1); // Remove the leading '&'. |
| 391 else | 391 else |
| 392 source_malformed_ = true; // '&' missing between two name-value pairs. | 392 source_malformed_ = true; // '&' missing between two name-value pairs. |
| 393 } | 393 } |
| 394 return success && !source_malformed_; | 394 return success && !source_malformed_; |
| 395 } | 395 } |
| 396 | 396 |
| 397 bool FormDataParserUrlEncoded::SetSource(base::StringPiece source) { | 397 bool FormDataParserUrlEncoded::SetSource(base::StringPiece source) { |
| 398 if (source_set_) | 398 if (source_set_) |
| 399 return false; // We do not allow multiple sources for this parser. | 399 return false; // We do not allow multiple sources for this parser. |
| 400 source_.set(source.data(), source.size()); | 400 source_.set(source.data(), static_cast<int>(source.size())); |
| 401 source_set_ = true; | 401 source_set_ = true; |
| 402 source_malformed_ = false; | 402 source_malformed_ = false; |
| 403 return true; | 403 return true; |
| 404 } | 404 } |
| 405 | 405 |
| 406 // static | 406 // static |
| 407 std::string FormDataParserMultipart::CreateBoundaryPatternFromLiteral( | 407 std::string FormDataParserMultipart::CreateBoundaryPatternFromLiteral( |
| 408 const std::string& literal) { | 408 const std::string& literal) { |
| 409 static const char quote[] = "\\Q"; | 409 static const char quote[] = "\\Q"; |
| 410 static const char unquote[] = "\\E"; | 410 static const char unquote[] = "\\E"; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 net::UnescapeRule::SPOOFING_AND_CONTROL_CHARS); | 527 net::UnescapeRule::SPOOFING_AND_CONTROL_CHARS); |
| 528 result->set_name(unescaped_name); | 528 result->set_name(unescaped_name); |
| 529 result->set_value(value); | 529 result->set_value(value); |
| 530 | 530 |
| 531 return return_value; | 531 return return_value; |
| 532 } | 532 } |
| 533 | 533 |
| 534 bool FormDataParserMultipart::SetSource(base::StringPiece source) { | 534 bool FormDataParserMultipart::SetSource(base::StringPiece source) { |
| 535 if (source.data() == NULL || !source_.empty()) | 535 if (source.data() == NULL || !source_.empty()) |
| 536 return false; | 536 return false; |
| 537 source_.set(source.data(), source.size()); | 537 source_.set(source.data(), static_cast<int>(source.size())); |
| 538 | 538 |
| 539 switch (state_) { | 539 switch (state_) { |
| 540 case STATE_INIT: | 540 case STATE_INIT: |
| 541 // Seek behind the preamble. | 541 // Seek behind the preamble. |
| 542 while (!StartsWithPattern(source_, dash_boundary_pattern_)) { | 542 while (!StartsWithPattern(source_, dash_boundary_pattern_)) { |
| 543 if (!RE2::Consume(&source_, preamble_pattern())) { | 543 if (!RE2::Consume(&source_, preamble_pattern())) { |
| 544 state_ = STATE_ERROR; | 544 state_ = STATE_ERROR; |
| 545 break; | 545 break; |
| 546 } | 546 } |
| 547 } | 547 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 if (value_pattern().Match(header, | 593 if (value_pattern().Match(header, |
| 594 kContentDispositionLength, header.size(), | 594 kContentDispositionLength, header.size(), |
| 595 RE2::UNANCHORED, groups, 2)) { | 595 RE2::UNANCHORED, groups, 2)) { |
| 596 value->set(groups[1].data(), groups[1].size()); | 596 value->set(groups[1].data(), groups[1].size()); |
| 597 *value_assigned = true; | 597 *value_assigned = true; |
| 598 } | 598 } |
| 599 return true; | 599 return true; |
| 600 } | 600 } |
| 601 | 601 |
| 602 } // namespace extensions | 602 } // namespace extensions |
| OLD | NEW |