diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-14 00:48:28 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-14 00:48:28 +0000 |
commit | 5d93738d664767ee0c7d3f0de8e5f68100de0b54 (patch) | |
tree | 76c6fda5692913280752a878800bec08e45ee53a /net | |
parent | 19f813b9ced7f01906f50a5895303f310a11482c (diff) | |
download | chromium_src-5d93738d664767ee0c7d3f0de8e5f68100de0b54.zip chromium_src-5d93738d664767ee0c7d3f0de8e5f68100de0b54.tar.gz chromium_src-5d93738d664767ee0c7d3f0de8e5f68100de0b54.tar.bz2 |
Revert 88553 - Revert 88510 - Escaping file names correctly. Also fixed a crush in chromeos debug build while saving a web page.
This change broke the official CrOS builder. I'll forward the error separately.
BUG=chromium-os:13130
TEST=Save a file with special characters like '#', '&', '"'.
Review URL: http://codereview.chromium.org/7057053
TBR=serya@chromium.org
Review URL: http://codereview.chromium.org/7046077
TBR=ericu@google.com
Review URL: http://codereview.chromium.org/7145014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/escape.cc | 5 | ||||
-rw-r--r-- | net/base/escape.h | 6 | ||||
-rw-r--r-- | net/base/escape_unittest.cc | 7 |
3 files changed, 13 insertions, 5 deletions
diff --git a/net/base/escape.cc b/net/base/escape.cc index 9f119d8..08eebfa 100644 --- a/net/base/escape.cc +++ b/net/base/escape.cc @@ -212,8 +212,9 @@ static const Charmap kUrlEscape( 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL ); -std::string EscapeUrlEncodedData(const std::string& path) { - return Escape(path, kUrlEscape, true); +std::string EscapeUrlEncodedData(const std::string& path, + bool use_plus) { + return Escape(path, kUrlEscape, use_plus); } // non-7bit diff --git a/net/base/escape.h b/net/base/escape.h index 6590329..ee8fd05 100644 --- a/net/base/escape.h +++ b/net/base/escape.h @@ -21,8 +21,10 @@ NET_API std::string EscapePath(const std::string& path); // Escape application/x-www-form-urlencoded content. This includes: // non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|} -// Space is escaped as + and other special characters as %XX (hex). -NET_API std::string EscapeUrlEncodedData(const std::string& path); +// Space is escaped as + (if use_plus is true) and other special characters +// as %XX (hex). +NET_API std::string EscapeUrlEncodedData(const std::string& path, + bool use_plus); // Escape all non-ASCII input. NET_API std::string EscapeNonASCII(const std::string& input); diff --git a/net/base/escape_unittest.cc b/net/base/escape_unittest.cc index 5211fdf..90714d4 100644 --- a/net/base/escape_unittest.cc +++ b/net/base/escape_unittest.cc @@ -147,7 +147,7 @@ TEST(EscapeTest, EscapeUrlEncodedData) { "\x02\n\x1d !\"#$%&'()*+,-./0123456789:;" "<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ" "[\\]^_`abcdefghijklmnopqrstuvwxyz" - "{|}~\x7f\x80\xff"), + "{|}~\x7f\x80\xff", true), // Escaped "%02%0A%1D+!%22%23%24%25%26%27()*%2B,-./0123456789:%3B" "%3C%3D%3E%3F%40ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -155,6 +155,11 @@ TEST(EscapeTest, EscapeUrlEncodedData) { "%7B%7C%7D~%7F%80%FF"); } +TEST(EscapeTest, EscapeUrlEncodedDataSpace) { + ASSERT_EQ(EscapeUrlEncodedData("a b", true), "a+b"); + ASSERT_EQ(EscapeUrlEncodedData("a b", false), "a%20b"); +} + TEST(EscapeTest, UnescapeURLComponentASCII) { const UnescapeURLCaseASCII unescape_cases[] = { {"", UnescapeRule::NORMAL, ""}, |