diff options
Diffstat (limited to 'www/chromium-uc/patches/core/ungoogled-chromium/block-trk-and-subdomains.patch')
| -rw-r--r-- | www/chromium-uc/patches/core/ungoogled-chromium/block-trk-and-subdomains.patch | 234 |
1 files changed, 234 insertions, 0 deletions
diff --git a/www/chromium-uc/patches/core/ungoogled-chromium/block-trk-and-subdomains.patch b/www/chromium-uc/patches/core/ungoogled-chromium/block-trk-and-subdomains.patch new file mode 100644 index 0000000..8b68a77 --- /dev/null +++ b/www/chromium-uc/patches/core/ungoogled-chromium/block-trk-and-subdomains.patch | |||
| @@ -0,0 +1,234 @@ | |||
| 1 | # Block all connection requests with 'qjz9zk' in the domain name or with a 'trk:' scheme. | ||
| 2 | # This patch is based on Iridium's 'net: add "trk:" scheme and help identify URLs being retrieved' | ||
| 3 | |||
| 4 | --- chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.orig | ||
| 5 | +++ chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc | ||
| 6 | @@ -56,6 +56,7 @@ ChromeAutocompleteSchemeClassifier::GetI | ||
| 7 | if (base::IsStringASCII(scheme) && | ||
| 8 | (ProfileIOData::IsHandledProtocol(scheme) || | ||
| 9 | base::LowerCaseEqualsASCII(scheme, content::kViewSourceScheme) || | ||
| 10 | + base::LowerCaseEqualsASCII(scheme, url::kTraceScheme) || | ||
| 11 | base::LowerCaseEqualsASCII(scheme, url::kJavaScriptScheme) || | ||
| 12 | base::LowerCaseEqualsASCII(scheme, url::kDataScheme))) { | ||
| 13 | return metrics::OmniboxInputType::URL; | ||
| 14 | --- chrome/browser/history/history_utils.cc.orig | ||
| 15 | +++ chrome/browser/history/history_utils.cc | ||
| 16 | @@ -21,6 +21,7 @@ bool CanAddURLToHistory(const GURL& url) | ||
| 17 | url.SchemeIs(content::kChromeDevToolsScheme) || | ||
| 18 | url.SchemeIs(content::kChromeUIScheme) || | ||
| 19 | url.SchemeIs(content::kViewSourceScheme) || | ||
| 20 | + url.SchemeIs(url::kTraceScheme) || | ||
| 21 | url.SchemeIs(chrome::kChromeNativeScheme) || | ||
| 22 | url.SchemeIs(chrome::kChromeSearchScheme) || | ||
| 23 | url.SchemeIs(dom_distiller::kDomDistillerScheme)) | ||
| 24 | --- chrome/browser/ui/singleton_tabs.cc.orig | ||
| 25 | +++ chrome/browser/ui/singleton_tabs.cc | ||
| 26 | @@ -99,7 +99,8 @@ int GetIndexOfExistingTab(Browser* brows | ||
| 27 | |||
| 28 | // Skip view-source tabs. This is needed because RewriteURLIfNecessary | ||
| 29 | // removes the "view-source:" scheme which leads to incorrect matching. | ||
| 30 | - if (tab_url.SchemeIs(content::kViewSourceScheme)) | ||
| 31 | + if (tab_url.SchemeIs(content::kViewSourceScheme) || | ||
| 32 | + tab_url.SchemeIs(url::kTraceScheme)) | ||
| 33 | continue; | ||
| 34 | |||
| 35 | GURL rewritten_tab_url = tab_url; | ||
| 36 | --- components/omnibox/browser/autocomplete_input.cc.orig | ||
| 37 | +++ components/omnibox/browser/autocomplete_input.cc | ||
| 38 | @@ -533,7 +533,8 @@ void AutocompleteInput::ParseForEmphasiz | ||
| 39 | // For the view-source and blob schemes, we should emphasize the host of the | ||
| 40 | // URL qualified by the view-source or blob prefix. | ||
| 41 | if ((base::LowerCaseEqualsASCII(scheme_str, kViewSourceScheme) || | ||
| 42 | - base::LowerCaseEqualsASCII(scheme_str, url::kBlobScheme)) && | ||
| 43 | + base::LowerCaseEqualsASCII(scheme_str, url::kBlobScheme) || | ||
| 44 | + base::LowerCaseEqualsASCII(scheme_str, url::kTraceScheme)) && | ||
| 45 | (static_cast<int>(text.length()) > after_scheme_and_colon)) { | ||
| 46 | // Obtain the URL prefixed by view-source or blob and parse it. | ||
| 47 | std::u16string real_url(text.substr(after_scheme_and_colon)); | ||
| 48 | --- components/url_formatter/url_fixer.cc.orig | ||
| 49 | +++ components/url_formatter/url_fixer.cc | ||
| 50 | @@ -562,6 +562,10 @@ GURL FixupURL(const std::string& text, c | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | + if (scheme == url::kTraceScheme) { | ||
| 55 | + return GURL(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | // We handle the file scheme separately. | ||
| 59 | if (scheme == url::kFileScheme) | ||
| 60 | return GURL(parts.scheme.is_valid() ? text : FixupPath(text)); | ||
| 61 | --- content/browser/child_process_security_policy_impl.cc.orig | ||
| 62 | +++ content/browser/child_process_security_policy_impl.cc | ||
| 63 | @@ -861,6 +861,7 @@ ChildProcessSecurityPolicyImpl::ChildPro | ||
| 64 | #endif // BUILDFLAG(ENABLE_WEBSOCKETS) | ||
| 65 | RegisterWebSafeScheme(url::kFtpScheme); | ||
| 66 | RegisterWebSafeScheme(url::kDataScheme); | ||
| 67 | + RegisterWebSafeScheme(url::kTraceScheme); | ||
| 68 | RegisterWebSafeScheme("feed"); | ||
| 69 | |||
| 70 | // TODO(nick): https://crbug.com/651534 blob: and filesystem: schemes embed | ||
| 71 | --- net/BUILD.gn.orig | ||
| 72 | +++ net/BUILD.gn | ||
| 73 | @@ -1010,6 +1010,8 @@ component("net") { | ||
| 74 | "url_request/report_sender.h", | ||
| 75 | "url_request/static_http_user_agent_settings.cc", | ||
| 76 | "url_request/static_http_user_agent_settings.h", | ||
| 77 | + "url_request/trk_protocol_handler.cc", | ||
| 78 | + "url_request/trk_protocol_handler.h", | ||
| 79 | "url_request/url_fetcher.cc", | ||
| 80 | "url_request/url_fetcher.h", | ||
| 81 | "url_request/url_fetcher_core.cc", | ||
| 82 | --- /dev/null | ||
| 83 | +++ net/url_request/trk_protocol_handler.cc | ||
| 84 | @@ -0,0 +1,25 @@ | ||
| 85 | +// Copyright (c) 2018 The ungoogled-chromium Authors. All rights reserved. | ||
| 86 | +// Use of this source code is governed by a BSD-style license that can be | ||
| 87 | +// found in the LICENSE file. | ||
| 88 | + | ||
| 89 | +#include "net/url_request/trk_protocol_handler.h" | ||
| 90 | + | ||
| 91 | +#include "base/logging.h" | ||
| 92 | +#include "net/base/net_errors.h" | ||
| 93 | +#include "net/url_request/url_request_error_job.h" | ||
| 94 | + | ||
| 95 | +namespace net { | ||
| 96 | + | ||
| 97 | +TrkProtocolHandler::TrkProtocolHandler() = default; | ||
| 98 | + | ||
| 99 | +std::unique_ptr<URLRequestJob> TrkProtocolHandler::CreateJob( | ||
| 100 | + URLRequest* request) const { | ||
| 101 | + LOG(ERROR) << "Blocked URL in TrkProtocolHandler: " << request->original_url(); | ||
| 102 | + return std::make_unique<URLRequestErrorJob>(request, ERR_BLOCKED_BY_CLIENT); | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +bool TrkProtocolHandler::IsSafeRedirectTarget(const GURL& location) const { | ||
| 106 | + return true; | ||
| 107 | +} | ||
| 108 | + | ||
| 109 | +} // namespace net | ||
| 110 | --- /dev/null | ||
| 111 | +++ net/url_request/trk_protocol_handler.h | ||
| 112 | @@ -0,0 +1,32 @@ | ||
| 113 | +// Copyright (c) 2018 The ungoogled-chromium Authors. All rights reserved. | ||
| 114 | +// Use of this source code is governed by a BSD-style license that can be | ||
| 115 | +// found in the LICENSE file. | ||
| 116 | + | ||
| 117 | +#ifndef NET_URL_REQUEST_TRK_PROTOCOL_HANDLER_H_ | ||
| 118 | +#define NET_URL_REQUEST_TRK_PROTOCOL_HANDLER_H_ | ||
| 119 | + | ||
| 120 | +#include "base/compiler_specific.h" | ||
| 121 | +#include "base/macros.h" | ||
| 122 | +#include "net/base/net_export.h" | ||
| 123 | +#include "net/url_request/url_request_job_factory.h" | ||
| 124 | + | ||
| 125 | +namespace net { | ||
| 126 | + | ||
| 127 | +class URLRequestJob; | ||
| 128 | + | ||
| 129 | +// Implements a ProtocolHandler for Trk jobs. | ||
| 130 | +class NET_EXPORT TrkProtocolHandler | ||
| 131 | + : public URLRequestJobFactory::ProtocolHandler { | ||
| 132 | + public: | ||
| 133 | + TrkProtocolHandler(); | ||
| 134 | + std::unique_ptr<URLRequestJob> CreateJob( | ||
| 135 | + URLRequest* request) const override; | ||
| 136 | + bool IsSafeRedirectTarget(const GURL& location) const override; | ||
| 137 | + | ||
| 138 | + private: | ||
| 139 | + DISALLOW_COPY_AND_ASSIGN(TrkProtocolHandler); | ||
| 140 | +}; | ||
| 141 | + | ||
| 142 | +} // namespace net | ||
| 143 | + | ||
| 144 | +#endif // NET_URL_REQUEST_TRK_PROTOCOL_HANDLER_H_ | ||
| 145 | --- net/url_request/url_request.cc.orig | ||
| 146 | +++ net/url_request/url_request.cc | ||
| 147 | @@ -12,6 +12,7 @@ | ||
| 148 | #include "base/compiler_specific.h" | ||
| 149 | #include "base/metrics/histogram_macros.h" | ||
| 150 | #include "base/rand_util.h" | ||
| 151 | +#include "base/strings/string_util.h" | ||
| 152 | #include "base/strings/utf_string_conversions.h" | ||
| 153 | #include "base/synchronization/lock.h" | ||
| 154 | #include "base/threading/thread_task_runner_handle.h" | ||
| 155 | @@ -46,6 +47,7 @@ | ||
| 156 | #include "net/url_request/url_request_redirect_job.h" | ||
| 157 | #include "url/gurl.h" | ||
| 158 | #include "url/origin.h" | ||
| 159 | +#include "url/url_constants.h" | ||
| 160 | |||
| 161 | using base::Time; | ||
| 162 | using std::string; | ||
| 163 | @@ -595,6 +597,12 @@ URLRequest::URLRequest(const GURL& url, | ||
| 164 | // Sanity check out environment. | ||
| 165 | DCHECK(base::ThreadTaskRunnerHandle::IsSet()); | ||
| 166 | |||
| 167 | + if (!url.SchemeIs(url::kTraceScheme) && | ||
| 168 | + base::EndsWith(url.host(), "qjz9zk", base::CompareCase::INSENSITIVE_ASCII)) { | ||
| 169 | + LOG(ERROR) << "Block URL in URLRequest: " << url; | ||
| 170 | + url_chain_[0] = GURL(url::kTraceScheme + (":" + url.possibly_invalid_spec())); | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | context->url_requests()->insert(this); | ||
| 174 | net_log_.BeginEvent(NetLogEventType::REQUEST_ALIVE, [&] { | ||
| 175 | return NetLogURLRequestConstructorParams(url, priority_, | ||
| 176 | --- net/url_request/url_request_context_builder.cc.orig | ||
| 177 | +++ net/url_request/url_request_context_builder.cc | ||
| 178 | @@ -46,6 +46,7 @@ | ||
| 179 | #include "net/quic/quic_stream_factory.h" | ||
| 180 | #include "net/ssl/ssl_config_service_defaults.h" | ||
| 181 | #include "net/url_request/static_http_user_agent_settings.h" | ||
| 182 | +#include "net/url_request/trk_protocol_handler.h" | ||
| 183 | #include "net/url_request/url_request_context.h" | ||
| 184 | #include "net/url_request/url_request_context_storage.h" | ||
| 185 | #include "net/url_request/url_request_job_factory.h" | ||
| 186 | @@ -546,6 +547,9 @@ std::unique_ptr<URLRequestContext> URLRe | ||
| 187 | } | ||
| 188 | protocol_handlers_.clear(); | ||
| 189 | |||
| 190 | + job_factory->SetProtocolHandler(url::kTraceScheme, | ||
| 191 | + std::make_unique<TrkProtocolHandler>()); | ||
| 192 | + | ||
| 193 | storage->set_job_factory(std::move(job_factory)); | ||
| 194 | |||
| 195 | return std::move(context); | ||
| 196 | --- url/url_constants.cc.orig | ||
| 197 | +++ url/url_constants.cc | ||
| 198 | @@ -28,6 +28,7 @@ const char kMailToScheme[] = "mailto"; | ||
| 199 | // See also: https://www.iana.org/assignments/uri-schemes/prov/quic-transport | ||
| 200 | const char kQuicTransportScheme[] = "quic-transport"; | ||
| 201 | const char kTelScheme[] = "tel"; | ||
| 202 | +const char kTraceScheme[] = "trk"; | ||
| 203 | const char kUrnScheme[] = "urn"; | ||
| 204 | const char kWsScheme[] = "ws"; | ||
| 205 | const char kWssScheme[] = "wss"; | ||
| 206 | --- url/url_constants.h.orig | ||
| 207 | +++ url/url_constants.h | ||
| 208 | @@ -32,6 +32,7 @@ COMPONENT_EXPORT(URL) extern const char | ||
| 209 | COMPONENT_EXPORT(URL) extern const char kMailToScheme[]; | ||
| 210 | COMPONENT_EXPORT(URL) extern const char kQuicTransportScheme[]; | ||
| 211 | COMPONENT_EXPORT(URL) extern const char kTelScheme[]; | ||
| 212 | +COMPONENT_EXPORT(URL) extern const char kTraceScheme[]; | ||
| 213 | COMPONENT_EXPORT(URL) extern const char kUrnScheme[]; | ||
| 214 | COMPONENT_EXPORT(URL) extern const char kWsScheme[]; | ||
| 215 | COMPONENT_EXPORT(URL) extern const char kWssScheme[]; | ||
| 216 | --- url/url_util.cc.orig | ||
| 217 | +++ url/url_util.cc | ||
| 218 | @@ -63,7 +63,7 @@ struct SchemeRegistry { | ||
| 219 | |||
| 220 | // Schemes that do not trigger mixed content warning. | ||
| 221 | std::vector<std::string> secure_schemes = { | ||
| 222 | - kHttpsScheme, kAboutScheme, kDataScheme, kQuicTransportScheme, kWssScheme, | ||
| 223 | + kHttpsScheme, kAboutScheme, kDataScheme, kTraceScheme, kQuicTransportScheme, kWssScheme, | ||
| 224 | }; | ||
| 225 | |||
| 226 | // Schemes that normal pages cannot link to or access (i.e., with the same | ||
| 227 | @@ -78,6 +78,7 @@ struct SchemeRegistry { | ||
| 228 | kAboutScheme, | ||
| 229 | kJavaScriptScheme, | ||
| 230 | kDataScheme, | ||
| 231 | + kTraceScheme, | ||
| 232 | }; | ||
| 233 | |||
| 234 | // Schemes that can be sent CORS requests. | ||
