diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 14:58:21 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 14:58:21 +0000 |
commit | b60ae4b0ea0bcdd455e45a4971da0ddfc6464c69 (patch) | |
tree | a42e9aab2c457c4018c0218afa7673460262dd08 | |
parent | be762d998ddb7f94f5192e373e9fd339eb3d5397 (diff) | |
download | chromium_src-b60ae4b0ea0bcdd455e45a4971da0ddfc6464c69.zip chromium_src-b60ae4b0ea0bcdd455e45a4971da0ddfc6464c69.tar.gz chromium_src-b60ae4b0ea0bcdd455e45a4971da0ddfc6464c69.tar.bz2 |
net: Move UnescapeRule into the net namespace.
BUG=64263
TEST=None
R=willchan@chromium.org
Review URL: http://codereview.chromium.org/8552002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110085 0039d316-1c4b-4281-b951-d872f2087c98
27 files changed, 93 insertions, 91 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 4841821..c8be0f1 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -575,7 +575,7 @@ string16 AutocompleteProvider::StringForURLDisplay(const GURL& url, url, languages, net::kFormatUrlOmitAll & ~(trim_http ? 0 : net::kFormatUrlOmitHTTP), - UnescapeRule::SPACES, NULL, NULL, NULL); + net::UnescapeRule::SPACES, NULL, NULL, NULL); } // AutocompleteResult --------------------------------------------------------- diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc index 7dba1cc..15c53b8 100644 --- a/chrome/browser/autocomplete/history_quick_provider.cc +++ b/chrome/browser/autocomplete/history_quick_provider.cc @@ -89,7 +89,7 @@ void HistoryQuickProvider::DoAutocomplete() { // Get the matching URLs from the DB. string16 term_string = autocomplete_input_.text(); term_string = net::UnescapeURLComponent(term_string, - UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); + net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); history::String16Vector terms( history::String16VectorFromString16(term_string, false)); ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms(terms); @@ -132,9 +132,8 @@ AutocompleteMatch HistoryQuickProvider::QuickMatchToACMatch( // Format the URL autocomplete presentation. std::vector<size_t> offsets = OffsetsFromTermMatches(history_match.url_matches); - match.contents = - net::FormatUrlWithOffsets(info.url(), languages_, net::kFormatUrlOmitAll, - UnescapeRule::SPACES, NULL, NULL, &offsets); + match.contents = net::FormatUrlWithOffsets(info.url(), languages_, + net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, NULL, NULL, &offsets); history::TermMatches new_matches = ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); match.contents_class = diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index 6d9f25b..cbbfb0e 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -910,7 +910,7 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch( match.fill_into_edit = AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), net::FormatUrl(info.url(), languages, format_types, - UnescapeRule::SPACES, NULL, NULL, + net::UnescapeRule::SPACES, NULL, NULL, &inline_autocomplete_offset)); if (!params->prevent_inline_autocomplete) match.inline_autocomplete_offset = inline_autocomplete_offset; @@ -919,7 +919,7 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch( size_t match_start = history_match.input_location; match.contents = net::FormatUrl(info.url(), languages, - format_types, UnescapeRule::SPACES, NULL, NULL, &match_start); + format_types, net::UnescapeRule::SPACES, NULL, NULL, &match_start); if ((match_start != string16::npos) && (inline_autocomplete_offset != string16::npos) && (inline_autocomplete_offset != match_start)) { diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc index d24f0e6..380bcb1 100644 --- a/chrome/browser/bookmarks/bookmark_utils.cc +++ b/chrome/browser/bookmarks/bookmark_utils.cc @@ -221,7 +221,7 @@ bool DoesBookmarkContainWords(const BookmarkNode* node, DoesBookmarkTextContainWords(UTF8ToUTF16(node->url().spec()), words) || DoesBookmarkTextContainWords(net::FormatUrl( node->url(), languages, net::kFormatUrlOmitNothing, - UnescapeRule::NORMAL, NULL, NULL, NULL), words); + net::UnescapeRule::NORMAL, NULL, NULL, NULL), words); } } // namespace diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index bc76afc..5c5edd7 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -859,7 +859,8 @@ std::string AboutHistograms(const std::string& query) { std::string unescaped_query; std::string unescaped_title("About Histograms"); if (!query.empty()) { - unescaped_query = net::UnescapeURLComponent(query, UnescapeRule::NORMAL); + unescaped_query = net::UnescapeURLComponent(query, + net::UnescapeRule::NORMAL); unescaped_title += " - " + unescaped_query; } @@ -890,7 +891,8 @@ static std::string AboutTracking(const std::string& query) { std::string unescaped_title("About Tracking"); if (!query.empty()) { unescaped_title += " - "; - unescaped_title += net::UnescapeURLComponent(query, UnescapeRule::NORMAL); + unescaped_title += net::UnescapeURLComponent(query, + net::UnescapeRule::NORMAL); } std::string data; AppendHeader(&data, 0, unescaped_title); diff --git a/chrome/browser/chromeos/web_socket_proxy.cc b/chrome/browser/chromeos/web_socket_proxy.cc index fcab182..c2f29ba 100644 --- a/chrome/browser/chromeos/web_socket_proxy.cc +++ b/chrome/browser/chromeos/web_socket_proxy.cc @@ -1252,7 +1252,7 @@ Conn::Status Conn::ConsumeHeader(struct evbuffer* evb) { if (key.len > 0) { requested_parameters_[std::string(piece + key.begin, key.len)] = net::UnescapeURLComponent(std::string(piece + value.begin, - value.len), UnescapeRule::URL_SPECIAL_CHARS); + value.len), net::UnescapeRule::URL_SPECIAL_CHARS); } } } diff --git a/chrome/browser/extensions/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc index 79134fd..7b64253 100644 --- a/chrome/browser/extensions/extension_updater_unittest.cc +++ b/chrome/browser/extensions/extension_updater_unittest.cc @@ -368,7 +368,7 @@ class ExtensionUpdaterTest : public testing::Test { EXPECT_EQ(2u, parts.size()); EXPECT_EQ("x", parts[0]); std::string decoded = net::UnescapeURLComponent( - parts[1], UnescapeRule::URL_SPECIAL_CHARS); + parts[1], net::UnescapeRule::URL_SPECIAL_CHARS); std::map<std::string, std::string> params; ExtractParameters(decoded, ¶ms); if (pending) { @@ -419,7 +419,7 @@ class ExtensionUpdaterTest : public testing::Test { EXPECT_EQ(2u, parts.size()); EXPECT_EQ("x", parts[0]); std::string decoded = net::UnescapeURLComponent( - parts[1], UnescapeRule::URL_SPECIAL_CHARS); + parts[1], net::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/history/in_memory_url_index.cc b/chrome/browser/history/in_memory_url_index.cc index b92a062..3dbbb79 100644 --- a/chrome/browser/history/in_memory_url_index.cc +++ b/chrome/browser/history/in_memory_url_index.cc @@ -171,7 +171,7 @@ void InMemoryURLIndex::IndexRow(const URLRow& row) { // Strip out username and password before saving and indexing. string16 url(net::FormatUrl(gurl, languages_, net::kFormatUrlOmitUsernamePassword, - UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, + net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS, NULL, NULL, NULL)); HistoryID history_id = static_cast<HistoryID>(row_id); @@ -196,7 +196,7 @@ void InMemoryURLIndex::AddRowWordsToIndex(const URLRow& row) { const GURL& gurl(row.url()); string16 url(net::FormatUrl(gurl, languages_, net::kFormatUrlOmitUsernamePassword, - UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, + net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS, NULL, NULL, NULL)); url = base::i18n::ToLower(url); String16Set url_words = String16SetFromString16(url); diff --git a/chrome/browser/net/browser_url_util.cc b/chrome/browser/net/browser_url_util.cc index 8471140..455f19f 100644 --- a/chrome/browser/net/browser_url_util.cc +++ b/chrome/browser/net/browser_url_util.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. @@ -24,7 +24,7 @@ void WriteURLToClipboard(const GURL& url, string16 text = url.SchemeIs(chrome::kMailToScheme) ? ASCIIToUTF16(url.path()) : net::FormatUrl(url, languages, net::kFormatUrlOmitNothing, - UnescapeRule::NONE, NULL, NULL, NULL); + net::UnescapeRule::NONE, NULL, NULL, NULL); ui::ScopedClipboardWriter scw(clipboard); scw.WriteURL(text); diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 486556b..2e025fc 100644 --- a/chrome/browser/net/url_fixer_upper.cc +++ b/chrome/browser/net/url_fixer_upper.cc @@ -173,7 +173,7 @@ static std::string FixupPath(const std::string& text) { GURL file_url = net::FilePathToFileURL(FilePath(filename)); if (file_url.is_valid()) { return UTF16ToUTF8(net::FormatUrl(file_url, std::string(), - net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, + net::kFormatUrlOmitUsernamePassword, net::UnescapeRule::NORMAL, NULL, NULL, NULL)); } @@ -550,11 +550,11 @@ GURL URLFixerUpper::FixupRelativeFile(const FilePath& base_dir, #if defined(OS_WIN) std::wstring unescaped = UTF8ToWide(net::UnescapeURLComponent( WideToUTF8(trimmed), - UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS)); + net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS)); #elif defined(OS_POSIX) std::string unescaped = net::UnescapeURLComponent( trimmed, - UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); + net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); #endif if (!ValidPathForFile(unescaped, &full_path)) @@ -569,7 +569,7 @@ GURL URLFixerUpper::FixupRelativeFile(const FilePath& base_dir, GURL file_url = net::FilePathToFileURL(full_path); if (file_url.is_valid()) return GURL(UTF16ToUTF8(net::FormatUrl(file_url, std::string(), - net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, + net::kFormatUrlOmitUsernamePassword, net::UnescapeRule::NORMAL, NULL, NULL, NULL))); // Invalid files fall through to regular processing. } diff --git a/chrome/browser/policy/device_management_service_unittest.cc b/chrome/browser/policy/device_management_service_unittest.cc index 34c585f..00bc701 100644 --- a/chrome/browser/policy/device_management_service_unittest.cc +++ b/chrome/browser/policy/device_management_service_unittest.cc @@ -247,24 +247,24 @@ class QueryParams { bool Check(const std::string& name, const std::string& expected_value) { bool found = false; for (ParamMap::const_iterator i(params_.begin()); i != params_.end(); ++i) { - std::string unescaped_name( - net::UnescapeURLComponent(i->first, - UnescapeRule::NORMAL | - UnescapeRule::SPACES | - UnescapeRule::URL_SPECIAL_CHARS | - UnescapeRule::CONTROL_CHARS | - UnescapeRule::REPLACE_PLUS_WITH_SPACE)); + std::string unescaped_name(net::UnescapeURLComponent( + i->first, + net::UnescapeRule::NORMAL | + net::UnescapeRule::SPACES | + net::UnescapeRule::URL_SPECIAL_CHARS | + net::UnescapeRule::CONTROL_CHARS | + net::UnescapeRule::REPLACE_PLUS_WITH_SPACE)); if (unescaped_name == name) { if (found) return false; found = true; - std::string unescaped_value( - net::UnescapeURLComponent(i->second, - UnescapeRule::NORMAL | - UnescapeRule::SPACES | - UnescapeRule::URL_SPECIAL_CHARS | - UnescapeRule::CONTROL_CHARS | - UnescapeRule::REPLACE_PLUS_WITH_SPACE)); + std::string unescaped_value(net::UnescapeURLComponent( + i->second, + net::UnescapeRule::NORMAL | + net::UnescapeRule::SPACES | + net::UnescapeRule::URL_SPECIAL_CHARS | + net::UnescapeRule::CONTROL_CHARS | + net::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 910b94f..efeb84e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_util.cc +++ b/chrome/browser/safe_browsing/safe_browsing_util.cc @@ -226,8 +226,8 @@ std::string Unescape(const std::string& url) { do { old_unescaped_str = unescaped_str; unescaped_str = net::UnescapeURLComponent(old_unescaped_str, - UnescapeRule::CONTROL_CHARS | UnescapeRule::SPACES | - UnescapeRule::URL_SPECIAL_CHARS); + net::UnescapeRule::CONTROL_CHARS | net::UnescapeRule::SPACES | + net::UnescapeRule::URL_SPECIAL_CHARS); } while (unescaped_str != old_unescaped_str && ++loop_var <= kMaxLoopIterations); diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index 38ec539..d4cae88 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -528,7 +528,8 @@ string16 TemplateURLRef::SearchTermToString16(const TemplateURL& host, std::string unescaped = net::UnescapeURLComponent( term, - UnescapeRule::REPLACE_PLUS_WITH_SPACE | UnescapeRule::URL_SPECIAL_CHARS); + net::UnescapeRule::REPLACE_PLUS_WITH_SPACE | + net::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/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model.cc index 588af39..f2425ef 100644 --- a/chrome/browser/ui/toolbar/toolbar_model.cc +++ b/chrome/browser/ui/toolbar/toolbar_model.cc @@ -58,7 +58,7 @@ string16 ToolbarModel::GetText() const { // the space. return AutocompleteInput::FormattedStringWithEquivalentMeaning( url, net::FormatUrl(url, languages, net::kFormatUrlOmitAll, - UnescapeRule::NORMAL, NULL, NULL, NULL)); + net::UnescapeRule::NORMAL, NULL, NULL, NULL)); } bool ToolbarModel::ShouldDisplayURL() const { diff --git a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc index 9e7f4f6..1ad3e7e 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc @@ -382,7 +382,7 @@ void BookmarkEditorView::Init() { // username/password, or unescape anything that changes the meaning. string16 url_text = net::FormatUrl(url, languages, net::kFormatUrlOmitAll & ~net::kFormatUrlOmitUsernamePassword, - UnescapeRule::SPACES, NULL, NULL, NULL); + net::UnescapeRule::SPACES, NULL, NULL, NULL); url_tf_ = new views::Textfield; url_tf_->SetText(UTF16ToWide(url_text)); diff --git a/chrome/browser/ui/webui/fileicon_source.cc b/chrome/browser/ui/webui/fileicon_source.cc index b397a76..30ee3da 100644 --- a/chrome/browser/ui/webui/fileicon_source.cc +++ b/chrome/browser/ui/webui/fileicon_source.cc @@ -30,7 +30,7 @@ void FileIconSource::StartDataRequest(const std::string& path, bool is_incognito, int request_id) { std::string escaped_path = net::UnescapeURLComponent(path, - UnescapeRule::SPACES); + net::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 e79381b..71d2ca8 100644 --- a/chrome/browser/ui/webui/ntp/app_launcher_handler.cc +++ b/chrome/browser/ui/webui/ntp/app_launcher_handler.cc @@ -53,8 +53,8 @@ namespace { -const UnescapeRule::Type kUnescapeRules = - UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS; +const net::UnescapeRule::Type kUnescapeRules = + net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS; extension_misc::AppLaunchBucket ParseLaunchSource( const std::string& launch_source) { diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc index 33df260..f5cf9f4 100644 --- a/chrome/common/extensions/extension_file_util.cc +++ b/chrome/common/extensions/extension_file_util.cc @@ -552,7 +552,7 @@ FilePath ExtensionURLToRelativeFilePath(const GURL& url) { // Drop the leading slashes and convert %-encoded UTF8 to regular UTF8. std::string file_path = net::UnescapeURLComponent(url_path, - UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); + net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); size_t skip = file_path.find_first_not_of("/\\"); if (skip != file_path.npos) file_path = file_path.substr(skip); diff --git a/chrome/renderer/external_extension_uitest.cc b/chrome/renderer/external_extension_uitest.cc index 7f16a09..d5afe82 100644 --- a/chrome/renderer/external_extension_uitest.cc +++ b/chrome/renderer/external_extension_uitest.cc @@ -120,8 +120,8 @@ void SearchProviderTest::FinishIsSearchProviderInstalledTest( // Unescapes and normalizes the actual result. std::string value = net::UnescapeURLComponent( escaped_value, - UnescapeRule::NORMAL | UnescapeRule::SPACES | - UnescapeRule::URL_SPECIAL_CHARS | UnescapeRule::CONTROL_CHARS); + net::UnescapeRule::NORMAL | net::UnescapeRule::SPACES | + net::UnescapeRule::URL_SPECIAL_CHARS | net::UnescapeRule::CONTROL_CHARS); value += "\n"; ReplaceSubstringsAfterOffset(&value, 0, "\r", ""); EXPECT_STREQ("1\n", value.c_str()); diff --git a/chrome/test/ui/ui_layout_test.cc b/chrome/test/ui/ui_layout_test.cc index 9db47f0..93e321c 100644 --- a/chrome/test/ui/ui_layout_test.cc +++ b/chrome/test/ui/ui_layout_test.cc @@ -236,8 +236,8 @@ void UILayoutTest::RunLayoutTest(const std::string& test_case_file_name, // Unescapes and normalizes the actual result. std::string value = net::UnescapeURLComponent(escaped_value, - UnescapeRule::NORMAL | UnescapeRule::SPACES | - UnescapeRule::URL_SPECIAL_CHARS | UnescapeRule::CONTROL_CHARS); + net::UnescapeRule::NORMAL | net::UnescapeRule::SPACES | + net::UnescapeRule::URL_SPECIAL_CHARS | net::UnescapeRule::CONTROL_CHARS); value += "\n"; ReplaceSubstringsAfterOffset(&value, 0, "\r", ""); diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index f6a74b7..7f48648 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -1424,7 +1424,7 @@ bool ChromeFrameUrl::ParseAttachExternalTabUrl() { profile_name_ = tokenizer.token(); // Escape out special characters like %20, etc. profile_name_ = net::UnescapeURLComponent(profile_name_, - UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); + net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS); } else { return false; } diff --git a/net/base/escape.cc b/net/base/escape.cc index f607a0e..8c488d1 100644 --- a/net/base/escape.cc +++ b/net/base/escape.cc @@ -13,6 +13,8 @@ #include "base/utf_offset_string_conversions.h" #include "base/utf_string_conversions.h" +namespace net { + namespace { const char kHexString[] = "0123456789ABCDEF"; @@ -249,8 +251,6 @@ static const Charmap kExternalHandlerCharmap( } // namespace -namespace net { - std::string EscapePath(const std::string& path) { return Escape(path, kPathCharmap, false); } diff --git a/net/base/escape.h b/net/base/escape.h index 9720a8d..bd9dc39 100644 --- a/net/base/escape.h +++ b/net/base/escape.h @@ -13,6 +13,38 @@ #include "base/string16.h" #include "net/base/net_export.h" +namespace net { + +// Escaping -------------------------------------------------------------------- + +// Escapes a file. This includes: +// non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|} +NET_EXPORT std::string EscapePath(const std::string& path); + +// Escapes application/x-www-form-urlencoded content. This includes: +// non-printable, non-7bit, and (including space) ?>=<;+'&%$#"![\]^`{|} +// Space is escaped as + (if use_plus is true) and other special characters +// as %XX (hex). +NET_EXPORT std::string EscapeUrlEncodedData(const std::string& path, + bool use_plus); + +// Escapes all non-ASCII input. +NET_EXPORT std::string EscapeNonASCII(const std::string& input); + +// Escapes characters in text suitable for use as an external protocol handler +// command. +// We %XX everything except alphanumerics and %-_.!~*'() and the restricted +// chracters (;/?:@&=+$,). +NET_EXPORT std::string EscapeExternalHandlerValue(const std::string& text); + +// Appends the given character to the output string, escaping the character if +// the character would be interpretted as an HTML delimiter. +NET_EXPORT void AppendEscapedCharForHTML(char c, std::string* output); + +// Escapes chars that might cause this text to be interpretted as HTML tags. +NET_EXPORT std::string EscapeForHTML(const std::string& text); +NET_EXPORT string16 EscapeForHTML(const string16& text); + // Unescaping ------------------------------------------------------------------ class UnescapeRule { @@ -55,38 +87,6 @@ class UnescapeRule { }; }; -namespace net { - -// Escaping -------------------------------------------------------------------- - -// escape a file. this includes: -// non-printable, non-7bit, and (including space) "#%:<>?[\]^`{|} -NET_EXPORT 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 + (if use_plus is true) and other special characters -// as %XX (hex). -NET_EXPORT std::string EscapeUrlEncodedData(const std::string& path, - bool use_plus); - -// Escape all non-ASCII input. -NET_EXPORT std::string EscapeNonASCII(const std::string& input); - -// Escapes characters in text suitable for use as an external protocol handler -// command. -// We %XX everything except alphanumerics and %-_.!~*'() and the restricted -// chracters (;/?:@&=+$,). -NET_EXPORT std::string EscapeExternalHandlerValue(const std::string& text); - -// Append the given character to the output string, escaping the character if -// the character would be interpretted as an HTML delimiter. -NET_EXPORT void AppendEscapedCharForHTML(char c, std::string* output); - -// Escape chars that might cause this text to be interpretted as HTML tags. -NET_EXPORT std::string EscapeForHTML(const std::string& text); -NET_EXPORT string16 EscapeForHTML(const string16& text); - // 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 @@ -120,7 +120,7 @@ NET_EXPORT string16 UnescapeAndDecodeUTF8URLComponentWithOffsets( UnescapeRule::Type rules, std::vector<size_t>* offsets_for_adjustment); -// Unescape the following ampersand character codes from |text|: +// Unescapes the following ampersand character codes from |text|: // < > & " ' NET_EXPORT string16 UnescapeForHTML(const string16& text); diff --git a/ui/base/text/text_elider.cc b/ui/base/text/text_elider.cc index 1fa38d4..06212c2 100644 --- a/ui/base/text/text_elider.cc +++ b/ui/base/text/text_elider.cc @@ -118,7 +118,7 @@ string16 ElideUrl(const GURL& url, // Get a formatted string and corresponding parsing of the url. url_parse::Parsed parsed; string16 url_string = net::FormatUrl(url, languages, net::kFormatUrlOmitAll, - UnescapeRule::SPACES, &parsed, NULL, NULL); + net::UnescapeRule::SPACES, &parsed, NULL, NULL); if (available_pixel_width <= 0) return url_string; @@ -397,7 +397,7 @@ SortedDisplayURL::SortedDisplayURL(const GURL& url, string16 host_minus_www = net::StripWWW(sort_host_); url_parse::Parsed parsed; display_url_ = net::FormatUrl(url, languages, - net::kFormatUrlOmitAll, UnescapeRule::SPACES, &parsed, &prefix_end_, + net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, &parsed, &prefix_end_, NULL); if (sort_host_.length() > host_minus_www.length()) { prefix_end_ += sort_host_.length() - host_minus_www.length(); diff --git a/webkit/blob/view_blob_internals_job.cc b/webkit/blob/view_blob_internals_job.cc index dbd491e..84a7497 100644 --- a/webkit/blob/view_blob_internals_job.cc +++ b/webkit/blob/view_blob_internals_job.cc @@ -134,7 +134,7 @@ void ViewBlobInternalsJob::DoWorkAsync() { StartsWithASCII(request_->url().query(), "remove=", true)) { std::string blob_url = request_->url().query().substr(strlen("remove=")); blob_url = net::UnescapeURLComponent(blob_url, - UnescapeRule::NORMAL | UnescapeRule::URL_SPECIAL_CHARS); + net::UnescapeRule::NORMAL | net::UnescapeRule::URL_SPECIAL_CHARS); blob_storage_controller_->RemoveBlob(GURL(blob_url)); } diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc index 1e8fff4..cbeba4b 100644 --- a/webkit/fileapi/file_system_util.cc +++ b/webkit/fileapi/file_system_util.cc @@ -62,8 +62,8 @@ bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type, return false; std::string path = net::UnescapeURLComponent(bare_url.path(), - UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS | - UnescapeRule::CONTROL_CHARS); + net::UnescapeRule::SPACES | net::UnescapeRule::URL_SPECIAL_CHARS | + net::UnescapeRule::CONTROL_CHARS); if (path.compare(0, strlen(kPersistentDir), kPersistentDir) == 0) { file_system_type = kFileSystemTypePersistent; path = path.substr(strlen(kPersistentDir)); diff --git a/webkit/glue/ftp_directory_listing_response_delegate.cc b/webkit/glue/ftp_directory_listing_response_delegate.cc index fc7ae59..b94ce73 100644 --- a/webkit/glue/ftp_directory_listing_response_delegate.cc +++ b/webkit/glue/ftp_directory_listing_response_delegate.cc @@ -93,8 +93,8 @@ void FtpDirectoryListingResponseDelegate::OnCompletedRequest() { } void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) { - UnescapeRule::Type unescape_rules = UnescapeRule::SPACES | - UnescapeRule::URL_SPECIAL_CHARS; + net::UnescapeRule::Type unescape_rules = net::UnescapeRule::SPACES | + net::UnescapeRule::URL_SPECIAL_CHARS; std::string unescaped_path = net::UnescapeURLComponent(response_url.path(), unescape_rules); SendDataToClient(net::GetDirectoryListingHeader( |