Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: net/http/http_content_disposition.cc

Issue 1107913003: Remove support for "name" parameter from Content-Disposition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust comment for clarity Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_content_disposition.h ('k') | net/http/http_content_disposition_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_tokenizer.h" 9 #include "base/strings/string_tokenizer.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // 390 //
391 void HttpContentDisposition::Parse(const std::string& header, 391 void HttpContentDisposition::Parse(const std::string& header,
392 const std::string& referrer_charset) { 392 const std::string& referrer_charset) {
393 DCHECK(type_ == INLINE); 393 DCHECK(type_ == INLINE);
394 DCHECK(filename_.empty()); 394 DCHECK(filename_.empty());
395 395
396 std::string::const_iterator pos = header.begin(); 396 std::string::const_iterator pos = header.begin();
397 std::string::const_iterator end = header.end(); 397 std::string::const_iterator end = header.end();
398 pos = ConsumeDispositionType(pos, end); 398 pos = ConsumeDispositionType(pos, end);
399 399
400 std::string name;
401 std::string filename; 400 std::string filename;
402 std::string ext_filename; 401 std::string ext_filename;
403 402
404 HttpUtil::NameValuePairsIterator iter(pos, end, ';'); 403 HttpUtil::NameValuePairsIterator iter(pos, end, ';');
405 while (iter.GetNext()) { 404 while (iter.GetNext()) {
406 if (filename.empty() && LowerCaseEqualsASCII(iter.name_begin(), 405 if (filename.empty() && LowerCaseEqualsASCII(iter.name_begin(),
407 iter.name_end(), 406 iter.name_end(),
408 "filename")) { 407 "filename")) {
409 DecodeFilenameValue(iter.value(), referrer_charset, &filename, 408 DecodeFilenameValue(iter.value(), referrer_charset, &filename,
410 &parse_result_flags_); 409 &parse_result_flags_);
411 if (!filename.empty()) 410 if (!filename.empty())
412 parse_result_flags_ |= HAS_FILENAME; 411 parse_result_flags_ |= HAS_FILENAME;
413 } else if (name.empty() && LowerCaseEqualsASCII(iter.name_begin(),
414 iter.name_end(),
415 "name")) {
416 DecodeFilenameValue(iter.value(), referrer_charset, &name, NULL);
417 if (!name.empty())
418 parse_result_flags_ |= HAS_NAME;
419 } else if (ext_filename.empty() && LowerCaseEqualsASCII(iter.name_begin(), 412 } else if (ext_filename.empty() && LowerCaseEqualsASCII(iter.name_begin(),
420 iter.name_end(), 413 iter.name_end(),
421 "filename*")) { 414 "filename*")) {
422 DecodeExtValue(iter.raw_value(), &ext_filename); 415 DecodeExtValue(iter.raw_value(), &ext_filename);
423 if (!ext_filename.empty()) 416 if (!ext_filename.empty())
424 parse_result_flags_ |= HAS_EXT_FILENAME; 417 parse_result_flags_ |= HAS_EXT_FILENAME;
425 } 418 }
426 } 419 }
427 420
428 if (!ext_filename.empty()) 421 if (!ext_filename.empty())
429 filename_ = ext_filename; 422 filename_ = ext_filename;
430 else if (!filename.empty()) 423 else
431 filename_ = filename; 424 filename_ = filename;
432 else
433 filename_ = name;
434 } 425 }
435 426
436 } // namespace net 427 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_content_disposition.h ('k') | net/http/http_content_disposition_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698