net/base/escape.h functions moved to base/strings/escape.h

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/dc7e817cd99dd6d902a5edbebf6dbc80a82e6753

commit dc7e817cd99dd6d902a5edbebf6dbc80a82e6753
Author: Victor Vasiliev <vasilvv@chromium.org>
Date:   Wed Apr 20 23:45:20 2022 +0000

    Move net/base/escape.h functions to base/strings/escape.h

    None of them contain any //net-specific code, and a lot of them are not
    even used inside of //net.

    Bug: 1100760
This commit is contained in:
Claudio DeSouza
2022-06-10 05:58:20 -04:00
committed by Emerick Rogul
parent 6fb54e0a3e
commit b1a36f528a
16 changed files with 34 additions and 44 deletions
@@ -19,7 +19,6 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "net/base/escape.h"
#include "net/base/url_util.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/origin.h"
-1
View File
@@ -19,7 +19,6 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "net/base/escape.h"
#include "net/base/url_util.h"
#include "url/origin.h"
@@ -21,7 +21,6 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "net/base/escape.h"
#include "net/base/url_util.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/base/page_transition_types.h"
@@ -38,7 +38,6 @@
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_url_handlers.h"
#include "net/base/backoff_entry.h"
#include "net/base/escape.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/extensions/extension_assets_manager_chromeos.h"
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/help/version_updater_mac.h"
#include "base/mac/foundation_util.h"
#include "base/strings/escape.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "brave/browser/sparkle_buildflags.h"
@@ -13,7 +14,6 @@
#include "chrome/browser/obsolete_system/obsolete_system.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "net/base/escape.h"
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(ENABLE_SPARKLE)
@@ -191,7 +191,7 @@ void VersionUpdaterMac::UpdateStatus(NSDictionary* dictionary) {
message += brave_l10n::GetLocalizedResourceUTF16String(
IDS_UPGRADE_ERROR_DETAILS);
message += u"<br/><pre>";
message += base::UTF8ToUTF16(net::EscapeForHTML(error_messages));
message += base::UTF8ToUTF16(base::EscapeForHTML(error_messages));
message += u"</pre>";
}
}
@@ -4,7 +4,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "components/url_formatter/url_formatter.h"
#include "net/base/escape.h"
#include "url/gurl.h"
namespace error_page {
@@ -33,6 +32,6 @@ std::u16string GetFailedUrlString(GURL failed_url) {
return url_formatter::FormatUrl(
failed_url, url_formatter::kFormatUrlOmitNothing,
net::UnescapeRule::NORMAL, nullptr, nullptr, nullptr);
base::UnescapeRule::NORMAL, nullptr, nullptr, nullptr);
}
} // namespace error_page
@@ -6,7 +6,7 @@
#include <string>
#include "base/memory/raw_ptr.h"
#include "brave/components/constants/pref_names.h"
#include "brave/common/pref_names.h"
#include "components/external_intents/android/jni_headers/InterceptNavigationDelegateImpl_jni.h"
#include "components/navigation_interception/intercept_navigation_delegate.h"
#include "components/prefs/pref_service.h"
@@ -15,7 +15,6 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
#include "net/base/escape.h"
#include "url/gurl.h"
namespace external_intents {
@@ -34,7 +33,7 @@ class BraveInterceptNavigationDelegate : public InterceptNavigationDelegate {
bool ShouldIgnoreNavigation(
content::NavigationHandle* navigation_handle) override {
if (ShouldPlayVideoInBrowser(GURL(net::EscapeExternalHandlerValue(
if (ShouldPlayVideoInBrowser(GURL(base::EscapeExternalHandlerValue(
navigation_handle->GetURL().spec()))))
return false;
@@ -8,6 +8,7 @@
#include <string>
#include <utility>
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_piece_forward.h"
#include "base/strings/string_util.h"
@@ -15,7 +16,6 @@
#include "brave/components/brave_rewards/common/url_constants.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/escape.h"
namespace {
@@ -28,10 +28,7 @@ GURL TranslateUrl(const GURL& url) {
std::string query;
if (url.has_query()) {
query = base::StrCat({
"?",
net::EscapeExternalHandlerValue(url.query())
});
query = base::StrCat({"?", base::EscapeExternalHandlerValue(url.query())});
}
base::ReplaceFirstSubstringAfterOffset(&path, 0, "/", "");
@@ -24,6 +24,7 @@
#include "base/json/json_string_value_serializer.h"
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/strings/escape.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
@@ -68,7 +69,6 @@
#include "content/public/browser/service_process_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/url_data_source.h"
#include "net/base/escape.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/base/url_util.h"
#include "net/http/http_status_code.h"
@@ -803,7 +803,7 @@ void RewardsServiceImpl::RestorePublishers() {
}
std::string RewardsServiceImpl::URIEncode(const std::string& value) {
return net::EscapeQueryParamValue(value, false);
return base::EscapeQueryParamValue(value, false);
}
void RewardsServiceImpl::Shutdown() {
@@ -13,7 +13,6 @@
#include "base/strings/stringprintf.h"
#include "brave/components/brave_wallet/browser/brave_wallet_constants.h"
#include "brave/components/constants/brave_services_key.h"
#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
@@ -11,7 +11,6 @@
#include "brave/components/brave_wallet/browser/brave_wallet_constants.h"
#include "brave/components/brave_wallet/browser/json_rpc_service.h"
#include "brave/components/brave_wallet/browser/swap_response_parser.h"
#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/base/url_util.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
@@ -9,6 +9,7 @@
#include <string>
#include <utility>
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "brave/common/url_constants.h"
@@ -23,7 +24,6 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_set.h"
#include "net/base/escape.h"
namespace webtorrent {
@@ -34,15 +34,15 @@ static GURL TranslateMagnetURL(const GURL& url) {
"/extension/brave_webtorrent.html?%s"}));
std::string translatedSpec(extension_page_url.spec());
base::ReplaceFirstSubstringAfterOffset(
&translatedSpec, 0, "%s",
net::EscapeQueryParamValue(url.spec(), true));
&translatedSpec, 0, "%s", base::EscapeQueryParamValue(url.spec(), true));
return GURL(translatedSpec);
}
static GURL TranslateTorrentUIURLReversed(const GURL& url) {
GURL translatedURL(net::UnescapeURLComponent(
url.query(), net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
net::UnescapeRule::PATH_SEPARATORS));
GURL translatedURL(base::UnescapeURLComponent(
url.query(),
base::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
base::UnescapeRule::PATH_SEPARATORS));
GURL::Replacements replacements;
replacements.SetRefStr(url.ref_piece());
return translatedURL.ReplaceComponents(replacements);
+7 -6
View File
@@ -10,6 +10,7 @@
#include "base/base64.h"
#include "base/json/json_writer.h"
#include "base/strings/escape.h"
#include "base/strings/stringprintf.h"
#include "base/task/task_runner_util.h"
#include "base/task/thread_pool.h"
@@ -22,7 +23,6 @@
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/storage_partition.h"
#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/base/url_util.h"
#include "services/network/public/cpp/resource_request.h"
@@ -69,7 +69,7 @@ void BuildFormEncoding(const std::string& key,
std::string* out) {
if (!out->empty())
out->append("&");
out->append(key + "=" + net::EscapeUrlEncodedData(value, true));
out->append(key + "=" + base::EscapeUrlEncodedData(value, true));
}
} // namespace
@@ -194,10 +194,11 @@ std::string FTXService::GetOAuthClientUrl() {
// This particular FTX Url has a strange format. It is parameterized as if
// it has a query param, except the params are the last path segment.
auto state = ntp_widget_utils::GetCryptoRandomString(false);
std::string path = std::string(oauth_path) + "/response_type=code" +
"&client_id=" + net::EscapeQueryParamValue(client_id_, true) +
"&state=" + net::EscapeQueryParamValue(state, true) +
"&redirect_uri=" + net::EscapeQueryParamValue(oauth_callback, true);
std::string path =
std::string(oauth_path) + "/response_type=code" +
"&client_id=" + base::EscapeQueryParamValue(client_id_, true) +
"&state=" + base::EscapeQueryParamValue(state, true) +
"&redirect_uri=" + base::EscapeQueryParamValue(oauth_callback, true);
GURL url = GetOAuthURL(path);
return url.spec();
}
@@ -21,6 +21,7 @@
#include "base/files/file_path.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/supports_user_data.h"
@@ -37,7 +38,6 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state_manager.h"
#include "ios/chrome/browser/favicon/favicon_service_factory.h"
#include "net/base/escape.h"
#include "ui/base/l10n/l10n_util.h"
using bookmarks::BookmarkCodec;
@@ -289,7 +289,7 @@ class Writer : public base::RefCountedThreadSafe<Writer> {
break;
case CONTENT:
utf8_string = net::EscapeForHTML(text);
utf8_string = base::EscapeForHTML(text);
break;
default:
@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/files/file_util.h"
#include "base/i18n/icu_string_conversions.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -21,7 +22,6 @@
#include "components/search_engines/search_terms_data.h"
#include "components/search_engines/template_url.h"
#include "net/base/data_url.h"
#include "net/base/escape.h"
#include "url/gurl.h"
#include "url/url_constants.h"
@@ -339,7 +339,7 @@ bool ParseFolderNameFromLine(const std::string& lineDt,
base::CodepageToUTF16(line.substr(tag_end, end - tag_end), charset.c_str(),
base::OnStringConversionError::SKIP, folder_name);
*folder_name = net::UnescapeForHTML(*folder_name);
*folder_name = base::UnescapeForHTML(*folder_name);
std::string attribute_list =
line.substr(std::size(kFolderOpen), tag_end - std::size(kFolderOpen) - 1);
@@ -409,14 +409,14 @@ bool ParseBookmarkFromLine(const std::string& lineDt,
// Title
base::CodepageToUTF16(line.substr(tag_end, end - tag_end), charset.c_str(),
base::OnStringConversionError::SKIP, title);
*title = net::UnescapeForHTML(*title);
*title = base::UnescapeForHTML(*title);
// URL
if (GetAttribute(attribute_list, kHrefAttribute, &value)) {
std::u16string url16;
base::CodepageToUTF16(value, charset.c_str(),
base::OnStringConversionError::SKIP, &url16);
url16 = net::UnescapeForHTML(url16);
url16 = base::UnescapeForHTML(url16);
*url = GURL(url16);
}
@@ -429,7 +429,7 @@ bool ParseBookmarkFromLine(const std::string& lineDt,
if (GetAttribute(attribute_list, kShortcutURLAttribute, &value)) {
base::CodepageToUTF16(value, charset.c_str(),
base::OnStringConversionError::SKIP, shortcut);
*shortcut = net::UnescapeForHTML(*shortcut);
*shortcut = base::UnescapeForHTML(*shortcut);
}
// Add date
@@ -445,7 +445,7 @@ bool ParseBookmarkFromLine(const std::string& lineDt,
if (GetAttribute(attribute_list, kPostDataAttribute, &value)) {
base::CodepageToUTF16(value, charset.c_str(),
base::OnStringConversionError::SKIP, post_data);
*post_data = net::UnescapeForHTML(*post_data);
*post_data = base::UnescapeForHTML(*post_data);
}
return true;
@@ -480,7 +480,7 @@ bool ParseMinimumBookmarkFromLine(const std::string& lineDt,
// Title
base::CodepageToUTF16(line.substr(tag_end, end - tag_end), charset.c_str(),
base::OnStringConversionError::SKIP, title);
*title = net::UnescapeForHTML(*title);
*title = base::UnescapeForHTML(*title);
// URL
std::string value;
@@ -490,7 +490,7 @@ bool ParseMinimumBookmarkFromLine(const std::string& lineDt,
std::u16string url16;
base::CodepageToUTF16(value, charset.c_str(),
base::OnStringConversionError::SKIP, &url16);
url16 = net::UnescapeForHTML(url16);
url16 = base::UnescapeForHTML(url16);
*url = GURL(url16);
} else {
@@ -12,9 +12,9 @@
#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/escape.h"
#include "base/strings/string_number_conversions.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "net/base/escape.h"
#include "net/http/http_status_code.h"
namespace ledger {
@@ -101,7 +101,7 @@ void TestLedgerClient::FetchFavIcon(const std::string& url,
}
std::string TestLedgerClient::URIEncode(const std::string& value) {
return net::EscapeQueryParamValue(value, false);
return base::EscapeQueryParamValue(value, false);
}
void TestLedgerClient::LoadURL(mojom::UrlRequestPtr request,