LeOSium_webview/LeOS/patches/Disable-UA-full-version.patch

62 lines
2.4 KiB
Diff
Raw Normal View History

2023-11-18 11:46:19 +01:00
From: uazo <uazo@users.noreply.github.com>
Date: Wed, 16 Feb 2022 14:28:58 +0000
Subject: Disable UA full version
getHighEntropyValues will return only the major version
Original License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
.../renderer/core/frame/navigator_ua_data.cc | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/third_party/blink/renderer/core/frame/navigator_ua_data.cc b/third_party/blink/renderer/core/frame/navigator_ua_data.cc
--- a/third_party/blink/renderer/core/frame/navigator_ua_data.cc
+++ b/third_party/blink/renderer/core/frame/navigator_ua_data.cc
@@ -7,6 +7,8 @@
#include "base/compiler_specific.h"
#include "base/task/single_thread_task_runner.h"
#include "third_party/blink/public/common/features.h"
+#include "base/version.h"
+#include "base/strings/strcat.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_metric_builder.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h"
#include "third_party/blink/public/common/privacy_budget/identifiable_surface.h"
@@ -40,6 +42,16 @@ void MaybeRecordMetric(bool record_identifiability,
.Record(execution_context->UkmRecorder());
}
+const String GetReducedVersionNumber(const std::string& fullVersion) {
+ base::Version version(fullVersion);
+ std::string version_str;
+ const std::vector<uint32_t>& components = version.components();
+ if (components.size() > 0) {
+ version_str = base::StrCat({base::NumberToString(components[0]), ".0.0.0"});
+ }
+ return String::FromUTF8(version_str);
+}
+
} // namespace
NavigatorUAData::NavigatorUAData(ExecutionContext* context)
@@ -78,7 +90,7 @@ void NavigatorUAData::SetFullVersionList(
const UserAgentBrandList& full_version_list) {
for (const auto& brand_version : full_version_list) {
AddBrandFullVersion(String::FromUTF8(brand_version.brand),
- String::FromUTF8(brand_version.version));
+ GetReducedVersionNumber(brand_version.version));
}
}
@@ -100,7 +112,7 @@ void NavigatorUAData::SetModel(const String& model) {
}
void NavigatorUAData::SetUAFullVersion(const String& ua_full_version) {
- ua_full_version_ = ua_full_version;
+ ua_full_version_ = GetReducedVersionNumber(ua_full_version.Ascii());
}
void NavigatorUAData::SetBitness(const String& bitness) {
--
2.25.1