summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 14:58:22 +0000
committerasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-04 14:58:22 +0000
commitdc7fd2564a9e1d57f3b1db35899caa6f1d763db9 (patch)
treeca4ed4fabb1ecac149db0eb2f55415f6c8aa0df5 /net
parentc14ad56370693394f52cf7ddd701c3a92cbb21fd (diff)
downloadchromium_src-dc7fd2564a9e1d57f3b1db35899caa6f1d763db9.zip
chromium_src-dc7fd2564a9e1d57f3b1db35899caa6f1d763db9.tar.gz
chromium_src-dc7fd2564a9e1d57f3b1db35899caa6f1d763db9.tar.bz2
Prefer 'filename' parameters if both 'name' and 'filename' parameters are specified in a Content-Disposition header.
BUG=129366 TEST=net_unittests Review URL: https://chromiumcodereview.appspot.com/10447019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140289 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/http/http_content_disposition.cc16
-rw-r--r--net/http/http_content_disposition_unittest.cc5
2 files changed, 16 insertions, 5 deletions
diff --git a/net/http/http_content_disposition.cc b/net/http/http_content_disposition.cc
index 5ec09c9..52d9f4f 100644
--- a/net/http/http_content_disposition.cc
+++ b/net/http/http_content_disposition.cc
@@ -69,6 +69,7 @@ void HttpContentDisposition::Parse(const std::string& header,
std::string::const_iterator end = header.end();
pos = ConsumeDispositionType(pos, end);
+ std::string name;
std::string filename;
std::string ext_filename;
@@ -78,10 +79,10 @@ void HttpContentDisposition::Parse(const std::string& header,
iter.name_end(),
"filename")) {
DecodeFilenameValue(iter.value(), referrer_charset, &filename);
- } else if (filename.empty() && LowerCaseEqualsASCII(iter.name_begin(),
- iter.name_end(),
- "name")) {
- DecodeFilenameValue(iter.value(), referrer_charset, &filename);
+ } else if (name.empty() && LowerCaseEqualsASCII(iter.name_begin(),
+ iter.name_end(),
+ "name")) {
+ DecodeFilenameValue(iter.value(), referrer_charset, &name);
} else if (ext_filename.empty() && LowerCaseEqualsASCII(iter.name_begin(),
iter.name_end(),
"filename*")) {
@@ -89,7 +90,12 @@ void HttpContentDisposition::Parse(const std::string& header,
}
}
- filename_ = ext_filename.empty() ? filename : ext_filename;
+ if (!ext_filename.empty())
+ filename_ = ext_filename;
+ else if (!filename.empty())
+ filename_ = filename;
+ else
+ filename_ = name;
}
} // namespace net
diff --git a/net/http/http_content_disposition_unittest.cc b/net/http/http_content_disposition_unittest.cc
index 7587c3e..240c699 100644
--- a/net/http/http_content_disposition_unittest.cc
+++ b/net/http/http_content_disposition_unittest.cc
@@ -147,6 +147,11 @@ TEST(HttpContentDispositionTest, Filename) {
{"attachment; filename*=windows-1252''caf%E9.png", "",
L"caf\x00e9.png"},
+ // Multiple filename, filename*, name parameters specified.
+ {"attachment; name=\"foo\"; filename=\"bar\"", "", L"bar"},
+ {"attachment; filename=\"bar\"; name=\"foo\"", "", L"bar"},
+ {"attachment; filename=\"bar\"; filename*=utf-8''baz", "", L"baz"},
+
// http://greenbytes.de/tech/tc2231/ filename* test cases.
// attwithisofn2231iso
{"attachment; filename*=iso-8859-1''foo-%E4.html", "",