diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-02 23:05:08 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-02 23:05:08 +0000 |
commit | 48797906a6bba708e777908049b8496035ed860f (patch) | |
tree | c3b9f76f773e92ad70e0f3352ff5d518be1b17d3 | |
parent | 2cec759bc34b3f3e7fb3a624474f8ea188a3c975 (diff) | |
download | chromium_src-48797906a6bba708e777908049b8496035ed860f.zip chromium_src-48797906a6bba708e777908049b8496035ed860f.tar.gz chromium_src-48797906a6bba708e777908049b8496035ed860f.tar.bz2 |
net: Move UnescapeURLComponent() functions into net namespace.
BUG=64263
TEST=None
R=willchan@chromium.org
Review URL: http://codereview.chromium.org/8109004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103677 0039d316-1c4b-4281-b951-d872f2087c98
20 files changed, 58 insertions, 58 deletions
diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc index da852c0..ae42585 100644 --- a/chrome/browser/autocomplete/history_quick_provider.cc +++ b/chrome/browser/autocomplete/history_quick_provider.cc @@ -21,9 +21,9 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" -#include "googleurl/src/url_parse.h" #include "content/common/content_notification_types.h" #include "content/common/notification_source.h" +#include "googleurl/src/url_parse.h" #include "googleurl/src/url_util.h" #include "net/base/escape.h" #include "net/base/net_util.h" @@ -88,7 +88,7 @@ void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) {} void HistoryQuickProvider::DoAutocomplete() { // Get the matching URLs from the DB. string16 term_string = autocomplete_input_.text(); - term_string = UnescapeURLComponent(term_string, + term_string = net::UnescapeURLComponent(term_string, UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); history::InMemoryURLIndex::String16Vector terms( InMemoryURLIndex::WordVectorFromString16(term_string, false)); diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 98a72aa..853dc9d 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -845,7 +845,7 @@ std::string AboutHistograms(const std::string& query) { std::string unescaped_query; std::string unescaped_title("About Histograms"); if (!query.empty()) { - unescaped_query = UnescapeURLComponent(query, UnescapeRule::NORMAL); + unescaped_query = net::UnescapeURLComponent(query, UnescapeRule::NORMAL); unescaped_title += " - " + unescaped_query; } @@ -877,7 +877,7 @@ static std::string AboutObjects(const std::string& query) { std::string unescaped_title("About Histograms"); if (!query.empty()) { unescaped_title += " - "; - unescaped_title += UnescapeURLComponent(query, UnescapeRule::NORMAL); + unescaped_title += net::UnescapeURLComponent(query, UnescapeRule::NORMAL); } std::string data; AppendHeader(&data, 0, unescaped_title); diff --git a/chrome/browser/extensions/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc index 98a09d7..c0ac93a 100644 --- a/chrome/browser/extensions/extension_updater_unittest.cc +++ b/chrome/browser/extensions/extension_updater_unittest.cc @@ -365,8 +365,8 @@ class ExtensionUpdaterTest : public testing::Test { base::SplitString(url.query(), '=', &parts); EXPECT_EQ(2u, parts.size()); EXPECT_EQ("x", parts[0]); - std::string decoded = UnescapeURLComponent(parts[1], - UnescapeRule::URL_SPECIAL_CHARS); + std::string decoded = net::UnescapeURLComponent( + parts[1], UnescapeRule::URL_SPECIAL_CHARS); std::map<std::string, std::string> params; ExtractParameters(decoded, ¶ms); if (pending) { @@ -416,8 +416,8 @@ class ExtensionUpdaterTest : public testing::Test { base::SplitString(url.query(), '=', &parts); EXPECT_EQ(2u, parts.size()); EXPECT_EQ("x", parts[0]); - std::string decoded = UnescapeURLComponent(parts[1], - UnescapeRule::URL_SPECIAL_CHARS); + std::string decoded = net::UnescapeURLComponent( + parts[1], UnescapeRule::URL_SPECIAL_CHARS); std::map<std::string, std::string> params; ExtractParameters(decoded, ¶ms); EXPECT_EQ("com.google.crx.blacklist", params["id"]); diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 4d85b42..486556b 100644 --- a/chrome/browser/net/url_fixer_upper.cc +++ b/chrome/browser/net/url_fixer_upper.cc @@ -548,11 +548,11 @@ GURL URLFixerUpper::FixupRelativeFile(const FilePath& base_dir, // escaped things. We need to go through 8-bit since the escaped values // only represent 8-bit values. #if defined(OS_WIN) - std::wstring unescaped = UTF8ToWide(UnescapeURLComponent( + std::wstring unescaped = UTF8ToWide(net::UnescapeURLComponent( WideToUTF8(trimmed), UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS)); #elif defined(OS_POSIX) - std::string unescaped = UnescapeURLComponent( + std::string unescaped = net::UnescapeURLComponent( trimmed, UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); #endif diff --git a/chrome/browser/policy/device_management_service_unittest.cc b/chrome/browser/policy/device_management_service_unittest.cc index a09f46f..dd09974 100644 --- a/chrome/browser/policy/device_management_service_unittest.cc +++ b/chrome/browser/policy/device_management_service_unittest.cc @@ -250,23 +250,23 @@ class QueryParams { bool found = false; for (ParamMap::const_iterator i(params_.begin()); i != params_.end(); ++i) { std::string unescaped_name( - UnescapeURLComponent(i->first, - UnescapeRule::NORMAL | - UnescapeRule::SPACES | - UnescapeRule::URL_SPECIAL_CHARS | - UnescapeRule::CONTROL_CHARS | - UnescapeRule::REPLACE_PLUS_WITH_SPACE)); + net::UnescapeURLComponent(i->first, + UnescapeRule::NORMAL | + UnescapeRule::SPACES | + UnescapeRule::URL_SPECIAL_CHARS | + UnescapeRule::CONTROL_CHARS | + UnescapeRule::REPLACE_PLUS_WITH_SPACE)); if (unescaped_name == name) { if (found) return false; found = true; std::string unescaped_value( - UnescapeURLComponent(i->second, - UnescapeRule::NORMAL | - UnescapeRule::SPACES | - UnescapeRule::URL_SPECIAL_CHARS | - UnescapeRule::CONTROL_CHARS | - UnescapeRule::REPLACE_PLUS_WITH_SPACE)); + net::UnescapeURLComponent(i->second, + UnescapeRule::NORMAL | + UnescapeRule::SPACES | + UnescapeRule::URL_SPECIAL_CHARS | + UnescapeRule::CONTROL_CHARS | + UnescapeRule::REPLACE_PLUS_WITH_SPACE)); if (unescaped_value != expected_value) return false; } diff --git a/chrome/browser/safe_browsing/safe_browsing_util.cc b/chrome/browser/safe_browsing/safe_browsing_util.cc index 29007c6..910b94f 100644 --- a/chrome/browser/safe_browsing/safe_browsing_util.cc +++ b/chrome/browser/safe_browsing/safe_browsing_util.cc @@ -225,7 +225,7 @@ std::string Unescape(const std::string& url) { int loop_var = 0; do { old_unescaped_str = unescaped_str; - unescaped_str = UnescapeURLComponent(old_unescaped_str, + unescaped_str = net::UnescapeURLComponent(old_unescaped_str, UnescapeRule::CONTROL_CHARS | UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); } while (unescaped_str != old_unescaped_str && ++loop_var <= diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index ced4654..93564ab 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -526,9 +526,9 @@ string16 TemplateURLRef::SearchTermToString16(const TemplateURL& host, const std::vector<std::string>& encodings = host.input_encodings(); string16 result; - std::string unescaped = - UnescapeURLComponent(term, UnescapeRule::REPLACE_PLUS_WITH_SPACE | - UnescapeRule::URL_SPECIAL_CHARS); + std::string unescaped = net::UnescapeURLComponent( + term, + UnescapeRule::REPLACE_PLUS_WITH_SPACE | UnescapeRule::URL_SPECIAL_CHARS); for (size_t i = 0; i < encodings.size(); ++i) { if (base::CodepageToUTF16(unescaped, encodings[i].c_str(), base::OnStringConversionError::FAIL, &result)) diff --git a/chrome/browser/ui/webui/fileicon_source.cc b/chrome/browser/ui/webui/fileicon_source.cc index cd5d936..b3ba838 100644 --- a/chrome/browser/ui/webui/fileicon_source.cc +++ b/chrome/browser/ui/webui/fileicon_source.cc @@ -29,7 +29,8 @@ FileIconSource::~FileIconSource() { void FileIconSource::StartDataRequest(const std::string& path, bool is_incognito, int request_id) { - std::string escaped_path = UnescapeURLComponent(path, UnescapeRule::SPACES); + std::string escaped_path = net::UnescapeURLComponent(path, + UnescapeRule::SPACES); #if defined(OS_WIN) // The path we receive has the wrong slashes and escaping for what we need; // this only appears to matter for getting icons from .exe files. diff --git a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc index 7ba788d..e891966 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -871,7 +871,7 @@ void AppLauncherHandler::RecordAppLaunchByURL( extension_misc::AppLaunchBucket bucket) { CHECK(bucket != extension_misc::APP_LAUNCH_BUCKET_INVALID); - GURL url(UnescapeURLComponent(escaped_url, kUnescapeRules)); + GURL url(net::UnescapeURLComponent(escaped_url, kUnescapeRules)); DCHECK(profile->GetExtensionService()); if (!profile->GetExtensionService()->IsInstalledApp(url)) return; diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc index 55ca7de..a8ad8bb 100644 --- a/chrome/common/extensions/extension_file_util.cc +++ b/chrome/common/extensions/extension_file_util.cc @@ -20,8 +20,8 @@ #include "chrome/common/extensions/extension_action.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_l10n_util.h" -#include "chrome/common/extensions/extension_messages.h" #include "chrome/common/extensions/extension_message_bundle.h" +#include "chrome/common/extensions/extension_messages.h" #include "chrome/common/extensions/extension_resource.h" #include "chrome/common/extensions/extension_sidebar_defaults.h" #include "content/common/json_value_serializer.h" @@ -550,7 +550,7 @@ FilePath ExtensionURLToRelativeFilePath(const GURL& url) { return FilePath(); // Drop the leading slashes and convert %-encoded UTF8 to regular UTF8. - std::string file_path = UnescapeURLComponent(url_path, + std::string file_path = net::UnescapeURLComponent(url_path, UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); size_t skip = file_path.find_first_not_of("/\\"); if (skip != file_path.npos) diff --git a/chrome/renderer/external_extension_uitest.cc b/chrome/renderer/external_extension_uitest.cc index 66a3fbd..7f16a09 100644 --- a/chrome/renderer/external_extension_uitest.cc +++ b/chrome/renderer/external_extension_uitest.cc @@ -118,7 +118,7 @@ void SearchProviderTest::FinishIsSearchProviderInstalledTest( TestTimeouts::action_max_timeout_ms()); // Unescapes and normalizes the actual result. - std::string value = UnescapeURLComponent( + std::string value = net::UnescapeURLComponent( escaped_value, UnescapeRule::NORMAL | UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS | UnescapeRule::CONTROL_CHARS); diff --git a/chrome/test/ui/ui_layout_test.cc b/chrome/test/ui/ui_layout_test.cc index ed2acbf..699b7c6 100644 --- a/chrome/test/ui/ui_layout_test.cc +++ b/chrome/test/ui/ui_layout_test.cc @@ -227,7 +227,7 @@ void UILayoutTest::RunLayoutTest(const std::string& test_case_file_name, status_cookie.c_str(), TestTimeouts::action_max_timeout_ms()); // Unescapes and normalizes the actual result. - std::string value = UnescapeURLComponent(escaped_value, + std::string value = net::UnescapeURLComponent(escaped_value, UnescapeRule::NORMAL | UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS | UnescapeRule::CONTROL_CHARS); value += "\n"; diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index b9dcc5a..283de44 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -1419,7 +1419,7 @@ bool ChromeFrameUrl::ParseAttachExternalTabUrl() { if (tokenizer.GetNext()) { profile_name_ = tokenizer.token(); // Escape out special characters like %20, etc. - profile_name_ = UnescapeURLComponent(profile_name_, + profile_name_ = net::UnescapeURLComponent(profile_name_, UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); } else { return false; diff --git a/net/base/escape.cc b/net/base/escape.cc index 893d032..3ca41f9 100644 --- a/net/base/escape.cc +++ b/net/base/escape.cc @@ -230,17 +230,6 @@ std::string EscapeExternalHandlerValue(const std::string& text) { return Escape(text, kExternalHandlerCharmap, false); } -std::string UnescapeURLComponent(const std::string& escaped_text, - UnescapeRule::Type rules) { - return UnescapeURLWithOffsetsImpl(escaped_text, rules, NULL); -} - -string16 UnescapeURLComponent(const string16& escaped_text, - UnescapeRule::Type rules) { - return UnescapeURLWithOffsetsImpl(escaped_text, rules, NULL); -} - - template <class str> void AppendEscapedCharForHTMLImpl(typename str::value_type c, str* output) { static const struct { @@ -291,6 +280,16 @@ string16 EscapeForHTML(const string16& input) { namespace net { +std::string UnescapeURLComponent(const std::string& escaped_text, + UnescapeRule::Type rules) { + return UnescapeURLWithOffsetsImpl(escaped_text, rules, NULL); +} + +string16 UnescapeURLComponent(const string16& escaped_text, + UnescapeRule::Type rules) { + return UnescapeURLWithOffsetsImpl(escaped_text, rules, NULL); +} + string16 UnescapeAndDecodeUTF8URLComponent(const std::string& text, UnescapeRule::Type rules, size_t* offset_for_adjustment) { diff --git a/net/base/escape.h b/net/base/escape.h index 1e4594c..eede454 100644 --- a/net/base/escape.h +++ b/net/base/escape.h @@ -85,6 +85,8 @@ class UnescapeRule { }; }; +namespace net { + // Unescapes |escaped_text| and returns the result. // Unescaping consists of looking for the exact pattern "%XX", where each X is // a hex digit, and converting to the character with the numerical value of @@ -100,8 +102,6 @@ NET_EXPORT std::string UnescapeURLComponent(const std::string& escaped_text, NET_EXPORT string16 UnescapeURLComponent(const string16& escaped_text, UnescapeRule::Type rules); -namespace net { - // Unescapes the given substring as a URL, and then tries to interpret the // result as being encoded as UTF-8. If the result is convertable into UTF-8, it // will be returned as converted. If it is not, the original escaped string will diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc index 56dd311..d448ad3 100644 --- a/net/ftp/ftp_network_transaction.cc +++ b/net/ftp/ftp_network_transaction.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -480,7 +480,7 @@ std::string FtpNetworkTransaction::GetRequestPathForFtpCommand( UnescapeRule::URL_SPECIAL_CHARS; // This may unescape to non-ASCII characters, but we allow that. See the // comment for IsValidFTPCommandString. - path = UnescapeURLComponent(path, unescape_rules); + path = net::UnescapeURLComponent(path, unescape_rules); if (system_type_ == SYSTEM_TYPE_VMS) { if (is_directory) diff --git a/webkit/blob/view_blob_internals_job.cc b/webkit/blob/view_blob_internals_job.cc index b105607..1d562c5 100644 --- a/webkit/blob/view_blob_internals_job.cc +++ b/webkit/blob/view_blob_internals_job.cc @@ -5,13 +5,13 @@ #include "webkit/blob/view_blob_internals_job.h" #include "base/compiler_specific.h" -#include "base/logging.h" #include "base/format_macros.h" #include "base/i18n/number_formatting.h" #include "base/i18n/time_formatting.h" +#include "base/logging.h" #include "base/message_loop.h" -#include "base/stringprintf.h" #include "base/string_util.h" +#include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "net/base/escape.h" #include "net/url_request/url_request.h" @@ -133,7 +133,7 @@ void ViewBlobInternalsJob::DoWorkAsync() { if (request_->url().has_query() && StartsWithASCII(request_->url().query(), "remove=", true)) { std::string blob_url = request_->url().query().substr(strlen("remove=")); - blob_url = UnescapeURLComponent(blob_url, + blob_url = net::UnescapeURLComponent(blob_url, UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS); blob_storage_controller_->UnregisterBlobUrl(GURL(blob_url)); } diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc index 7d2dcb0..a02e2a7 100644 --- a/webkit/fileapi/file_system_operation.cc +++ b/webkit/fileapi/file_system_operation.cc @@ -806,7 +806,7 @@ bool FileSystemOperation::VerifyFileSystemPathForRead( // On Windows, the path will look like /C:/foo/bar; we need to remove the // leading slash to make it valid. But if it's empty, we shouldn't do // anything. - std::string temp = UnescapeURLComponent(path.path(), + std::string temp = net::UnescapeURLComponent(path.path(), UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); if (temp.size()) temp = temp.substr(1); @@ -861,7 +861,7 @@ bool FileSystemOperation::VerifyFileSystemPathForWrite( // On Windows, the path will look like /C:/foo/bar; we need to remove the // leading slash to make it valid. But if it's empty, we shouldn't do // anything. - std::string temp = UnescapeURLComponent(path.path(), + std::string temp = net::UnescapeURLComponent(path.path(), UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); if (temp.size()) temp = temp.substr(1); diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc index 1314dfc..1e8fff4 100644 --- a/webkit/fileapi/file_system_util.cc +++ b/webkit/fileapi/file_system_util.cc @@ -61,7 +61,7 @@ bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type, if (origin.is_empty()) return false; - std::string path = UnescapeURLComponent(bare_url.path(), + std::string path = net::UnescapeURLComponent(bare_url.path(), UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS | UnescapeRule::CONTROL_CHARS); if (path.compare(0, strlen(kPersistentDir), kPersistentDir) == 0) { diff --git a/webkit/glue/ftp_directory_listing_response_delegate.cc b/webkit/glue/ftp_directory_listing_response_delegate.cc index 33a3f8c..fc7ae59 100644 --- a/webkit/glue/ftp_directory_listing_response_delegate.cc +++ b/webkit/glue/ftp_directory_listing_response_delegate.cc @@ -11,8 +11,8 @@ #include "base/logging.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" -#include "base/utf_string_conversions.h" #include "base/time.h" +#include "base/utf_string_conversions.h" #include "net/base/escape.h" #include "net/base/net_errors.h" #include "net/base/net_util.h" @@ -95,10 +95,10 @@ void FtpDirectoryListingResponseDelegate::OnCompletedRequest() { void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) { UnescapeRule::Type unescape_rules = UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS; - std::string unescaped_path = UnescapeURLComponent(response_url.path(), - unescape_rules); + std::string unescaped_path = net::UnescapeURLComponent(response_url.path(), + unescape_rules); SendDataToClient(net::GetDirectoryListingHeader( - ConvertPathToUTF16(unescaped_path))); + ConvertPathToUTF16(unescaped_path))); // If this isn't top level directory (i.e. the path isn't "/",) // add a link to the parent directory. |