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

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

Issue 9317018: referrer_charset is a lie. It's really the user's default_charset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« 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/logging.h" 7 #include "base/logging.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/net_util.h" 9 #include "net/base/net_util.h"
10 #include "net/http/http_util.h" 10 #include "net/http/http_util.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 HttpContentDisposition::HttpContentDisposition( 14 HttpContentDisposition::HttpContentDisposition(
15 const std::string& header, const std::string& referrer_charset) 15 const std::string& header, const std::string& default_charset)
16 : type_(INLINE) { 16 : type_(INLINE) {
17 Parse(header, referrer_charset); 17 Parse(header, default_charset);
18 } 18 }
19 19
20 HttpContentDisposition::~HttpContentDisposition() { 20 HttpContentDisposition::~HttpContentDisposition() {
21 } 21 }
22 22
23 std::string::const_iterator HttpContentDisposition::ConsumeDispositionType( 23 std::string::const_iterator HttpContentDisposition::ConsumeDispositionType(
24 std::string::const_iterator begin, std::string::const_iterator end) { 24 std::string::const_iterator begin, std::string::const_iterator end) {
25 DCHECK(type_ == INLINE); 25 DCHECK(type_ == INLINE);
26 std::string::const_iterator delimiter = std::find(begin, end, ';'); 26 std::string::const_iterator delimiter = std::find(begin, end, ';');
27 27
(...skipping 26 matching lines...) Expand all
54 // disposition-parm = filename-parm | disp-ext-parm 54 // disposition-parm = filename-parm | disp-ext-parm
55 // 55 //
56 // filename-parm = "filename" "=" value 56 // filename-parm = "filename" "=" value
57 // | "filename*" "=" ext-value 57 // | "filename*" "=" ext-value
58 // 58 //
59 // disp-ext-parm = token "=" value 59 // disp-ext-parm = token "=" value
60 // | ext-token "=" ext-value 60 // | ext-token "=" ext-value
61 // ext-token = <the characters in token, followed by "*"> 61 // ext-token = <the characters in token, followed by "*">
62 // 62 //
63 void HttpContentDisposition::Parse(const std::string& header, 63 void HttpContentDisposition::Parse(const std::string& header,
64 const std::string& referrer_charset) { 64 const std::string& default_charset) {
65 DCHECK(type_ == INLINE); 65 DCHECK(type_ == INLINE);
66 DCHECK(filename_.empty()); 66 DCHECK(filename_.empty());
67 67
68 std::string::const_iterator pos = header.begin(); 68 std::string::const_iterator pos = header.begin();
69 std::string::const_iterator end = header.end(); 69 std::string::const_iterator end = header.end();
70 pos = ConsumeDispositionType(pos, end); 70 pos = ConsumeDispositionType(pos, end);
71 71
72 std::string filename; 72 std::string filename;
73 std::string ext_filename; 73 std::string ext_filename;
74 74
75 HttpUtil::NameValuePairsIterator iter(pos, end, ';'); 75 HttpUtil::NameValuePairsIterator iter(pos, end, ';');
76 while (iter.GetNext()) { 76 while (iter.GetNext()) {
77 if (filename.empty() && LowerCaseEqualsASCII(iter.name_begin(), 77 if (filename.empty() && LowerCaseEqualsASCII(iter.name_begin(),
78 iter.name_end(), 78 iter.name_end(),
79 "filename")) { 79 "filename")) {
80 DecodeFilenameValue(iter.value(), referrer_charset, &filename); 80 DecodeFilenameValue(iter.value(), default_charset, &filename);
81 } else if (filename.empty() && LowerCaseEqualsASCII(iter.name_begin(), 81 } else if (filename.empty() && LowerCaseEqualsASCII(iter.name_begin(),
82 iter.name_end(), 82 iter.name_end(),
83 "name")) { 83 "name")) {
84 DecodeFilenameValue(iter.value(), referrer_charset, &filename); 84 DecodeFilenameValue(iter.value(), default_charset, &filename);
85 } else if (ext_filename.empty() && LowerCaseEqualsASCII(iter.name_begin(), 85 } else if (ext_filename.empty() && LowerCaseEqualsASCII(iter.name_begin(),
86 iter.name_end(), 86 iter.name_end(),
87 "filename*")) { 87 "filename*")) {
88 DecodeExtValue(iter.raw_value(), &ext_filename); 88 DecodeExtValue(iter.raw_value(), &ext_filename);
89 } 89 }
90 } 90 }
91 91
92 filename_ = ext_filename.empty() ? filename : ext_filename; 92 filename_ = ext_filename.empty() ? filename : ext_filename;
93 } 93 }
94 94
95 } // namespace net 95 } // 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