Files
camoufox/patches/timezone-spoofing.patch
T
Nirupam Bhowmick 0e7cef4ca9 fix: update timezone-spoofing.patch for Firefox 146 compatibility
- Updated line numbers and context in intl/components/moz.build
- Changed TimeZone::TryCreate parameter from char16_t to char in TimeZone.cpp
- Added explicit reinterpret_cast for zoneID assignment to match new char-based API
2025-12-28 20:15:48 +00:00

50 lines
1.6 KiB
Diff

diff --git a/intl/components/moz.build b/intl/components/moz.build
index 8e854bba70..72213b13cf 100644
--- a/intl/components/moz.build
+++ b/intl/components/moz.build
@@ -85,3 +85,6 @@ if not CONFIG["MOZ_SYSTEM_ICU"]:
DEFINES["MOZ_HAS_MOZGLUE"] = True
Library("intlcomponents")
+
+# DOM Mask
+LOCAL_INCLUDES += ["/camoucfg"]
\ No newline at end of file
diff --git a/intl/components/src/TimeZone.cpp b/intl/components/src/TimeZone.cpp
index fb4c0657ba..1b18d87681 100644
--- a/intl/components/src/TimeZone.cpp
+++ b/intl/components/src/TimeZone.cpp
@@ -8,7 +8,8 @@
#include <algorithm>
#include <string_view>
-
+#include "unicode/unistr.h"
+#include "MaskConfig.hpp"
#include "unicode/uenum.h"
#if MOZ_INTL_USE_ICU_CPP_TIMEZONE
# include "unicode/basictz.h"
@@ -21,7 +22,21 @@ Result<UniquePtr<TimeZone>, ICUError> TimeZone::TryCreate(
Maybe<Span<const char>> aTimeZoneOverride) {
const char* zoneID = nullptr;
int32_t zoneIDLen = 0;
- if (aTimeZoneOverride) {
+
+ if (auto value = MaskConfig::GetString("timezone")) {
+ std::string camouTimeZone = value.value();
+
+ // Because we don't have access to NS_ConvertUTF8toUTF16 here,
+ // convert UTF-8 to UTF-16 using ICU's UnicodeString
+ icu::UnicodeString uniStr = icu::UnicodeString::fromUTF8(camouTimeZone);
+
+ if (uniStr.isBogus()) {
+ return Err(ICUError::InternalError);
+ }
+
+ zoneIDLen = uniStr.length();
+ zoneID = reinterpret_cast<const char*>(uniStr.getBuffer());
+ } else if (aTimeZoneOverride) {
zoneIDLen = static_cast<int32_t>(aTimeZoneOverride->Length());
zoneID = aTimeZoneOverride->Elements();
}