Chromium Code Reviews| 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 "net/http/http_content_disposition.h" | 5 #include "net/http/http_content_disposition.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_piece.h" | |
| 9 #include "base/strings/string_tokenizer.h" | 10 #include "base/strings/string_tokenizer.h" |
| 10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
| 14 #include "net/base/net_string_util.h" | 15 #include "net/base/net_string_util.h" |
| 15 #include "net/http/http_util.h" | 16 #include "net/http/http_util.h" |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 | 19 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 HttpContentDisposition::~HttpContentDisposition() { | 342 HttpContentDisposition::~HttpContentDisposition() { |
| 342 } | 343 } |
| 343 | 344 |
| 344 std::string::const_iterator HttpContentDisposition::ConsumeDispositionType( | 345 std::string::const_iterator HttpContentDisposition::ConsumeDispositionType( |
| 345 std::string::const_iterator begin, std::string::const_iterator end) { | 346 std::string::const_iterator begin, std::string::const_iterator end) { |
| 346 DCHECK(type_ == INLINE); | 347 DCHECK(type_ == INLINE); |
| 347 std::string::const_iterator delimiter = std::find(begin, end, ';'); | 348 std::string::const_iterator delimiter = std::find(begin, end, ';'); |
| 348 | 349 |
| 349 std::string::const_iterator type_begin = begin; | 350 std::string::const_iterator type_begin = begin; |
| 350 std::string::const_iterator type_end = delimiter; | 351 std::string::const_iterator type_end = delimiter; |
| 351 HttpUtil::TrimLWS(&type_begin, &type_end); | 352 HttpUtil::TrimLWS(&type_begin, &type_end); |
|
mmenke
2016/08/10 20:15:19
There's a base::StringPiece version of this, too.
Adam Rice
2016/08/12 05:48:33
Done.
HttpUtil::HeadersIterator can be cleaned up
| |
| 352 | 353 |
| 353 // If the disposition-type isn't a valid token the then the | 354 // If the disposition-type isn't a valid token the then the |
| 354 // Content-Disposition header is malformed, and we treat the first bytes as | 355 // Content-Disposition header is malformed, and we treat the first bytes as |
| 355 // a parameter rather than a disposition-type. | 356 // a parameter rather than a disposition-type. |
| 356 if (!HttpUtil::IsToken(type_begin, type_end)) | 357 if (type_begin == type_end || |
| 358 !HttpUtil::IsToken( | |
| 359 base::StringPiece(&*type_begin, type_end - type_begin))) { | |
| 357 return begin; | 360 return begin; |
| 361 } | |
| 358 | 362 |
| 359 parse_result_flags_ |= HAS_DISPOSITION_TYPE; | 363 parse_result_flags_ |= HAS_DISPOSITION_TYPE; |
| 360 | 364 |
| 361 DCHECK(std::find(type_begin, type_end, '=') == type_end); | 365 DCHECK(std::find(type_begin, type_end, '=') == type_end); |
| 362 | 366 |
| 363 if (base::LowerCaseEqualsASCII(base::StringPiece(type_begin, type_end), | 367 if (base::LowerCaseEqualsASCII(base::StringPiece(type_begin, type_end), |
| 364 "inline")) { | 368 "inline")) { |
| 365 type_ = INLINE; | 369 type_ = INLINE; |
| 366 } else if (base::LowerCaseEqualsASCII(base::StringPiece(type_begin, type_end), | 370 } else if (base::LowerCaseEqualsASCII(base::StringPiece(type_begin, type_end), |
| 367 "attachment")) { | 371 "attachment")) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 } | 427 } |
| 424 } | 428 } |
| 425 | 429 |
| 426 if (!ext_filename.empty()) | 430 if (!ext_filename.empty()) |
| 427 filename_ = ext_filename; | 431 filename_ = ext_filename; |
| 428 else | 432 else |
| 429 filename_ = filename; | 433 filename_ = filename; |
| 430 } | 434 } |
| 431 | 435 |
| 432 } // namespace net | 436 } // namespace net |
| OLD | NEW |