summaryrefslogtreecommitdiffstats
path: root/net/base/net_util.h
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 06:03:16 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 06:03:16 +0000
commit56eab2f216ce86217149753a407f981cb6d5de6c (patch)
treebf4b45a8fbb845b5ec177332df0ebafcfaedb98f /net/base/net_util.h
parent9b961c91eeb8ba43be7918563a07432cbcb1c4df (diff)
downloadchromium_src-56eab2f216ce86217149753a407f981cb6d5de6c.zip
chromium_src-56eab2f216ce86217149753a407f981cb6d5de6c.tar.gz
chromium_src-56eab2f216ce86217149753a407f981cb6d5de6c.tar.bz2
Improve parsing of the Content-Disposition header
Previous, we were using GetHeaderParamValue to parse the Content-Disposition header, which describes itself as a "quick and dirty implementation." After this patch, we use more of our normal HTTP parsing machinery, making our parsing much less quirky and better aligned with RFC 6266. Some notes: 1) Many of the test cases for parsing the Content-Disposition header included the string "Content-Disposition: " in the input. I've looked through all of the callers of these functions, and that seems to be completely bogus. The old parser wasn't careful enough to see that as a problem, but the new one follows the spec more closely. I've updated the test cases to remove this string. 2) After this patch, there's a bunch of code in net_util.cc that really should be moved to http_content_disposition.cc. I didn't move that code in this patch because I didn't want this path to be too large. I'll move it in a future patch. 3) In a future patch, I'll audit the codebase for callers of GetHeaderParamValue. With any luck, we'll be able to remove them all and delete this less-than-amazing function. BUG=65423 Review URL: http://codereview.chromium.org/9234055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119378 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/net_util.h')
-rw-r--r--net/base/net_util.h32
1 files changed, 6 insertions, 26 deletions
diff --git a/net/base/net_util.h b/net/base/net_util.h
index f72938f..fed20f0 100644
--- a/net/base/net_util.h
+++ b/net/base/net_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -151,31 +151,11 @@ NET_EXPORT std::string GetHeaderParamValue(const std::string& header,
const std::string& param_name,
QuoteRule::Type quote_rule);
-// Return the filename extracted from Content-Disposition header. The following
-// formats are tried in order listed below:
-//
-// 1. RFC 5987
-// 2. RFC 2047
-// 3. Raw-8bit-characters :
-// a. UTF-8, b. referrer_charset, c. default os codepage.
-// 4. %-escaped UTF-8.
-//
-// In step 3, if referrer_charset is empty(i.e. unknown), 3b is skipped.
-// In step 4, the fallback charsets tried in step 3 are not tried. We
-// can consider doing that later.
-//
-// When a param value is ASCII, but is not in format #2 or format #4 above,
-// it is returned as it is unless it's pretty close to two supported
-// formats but not well-formed. In that case, an empty string is returned.
-//
-// In any case, a caller must check for the empty return value and resort to
-// another means to get a filename (e.g. url).
-//
-// This function does not do any escaping and callers are responsible for
-// escaping 'unsafe' characters (e.g. (back)slash, colon) as they see fit.
-NET_EXPORT_PRIVATE std::string GetFileNameFromCD(
- const std::string& header,
- const std::string& referrer_charset);
+// TODO(abarth): Move these functions to http_content_disposition.cc.
+bool DecodeFilenameValue(const std::string& input,
+ const std::string& referrer_charset,
+ std::string* output);
+bool DecodeExtValue(const std::string& value, std::string* output);
// Converts the given host name to unicode characters. This can be called for
// any host name, if the input is not IDN or is invalid in some way, we'll just