From 40fbce61e49cbe36f008a9dcaf7d96a630028b2c Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Tue, 14 Apr 2026 19:24:24 +0100 Subject: [PATCH] Remove init_script system timezone fallback that poisons storage (#560) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The else branch in _build_init_script() reads the system timezone via Intl.DateTimeFormat().resolvedOptions().timeZone and stores it via setTimezone(). When geoip resolves a different timezone (set later via CAMOU_CONFIG/launch_options), the storage value from the init_script takes precedence — workers read the wrong timezone and the C++ MaskConfig fallback (PR #546) is never reached. Fix: only call setTimezone() when an explicit timezone value is provided. When omitted, timezone propagation is handled entirely by the C++ side (SetNewDocument + TimezoneManager::GetTimezone MaskConfig fallback). Companion to #546 (Fix worker timezone leak when using geoip/proxy). Co-authored-by: Claude Opus 4.6 (1M context) --- pythonlib/camoufox/fingerprints.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pythonlib/camoufox/fingerprints.py b/pythonlib/camoufox/fingerprints.py index bc2467e..da6ddd2 100644 --- a/pythonlib/camoufox/fingerprints.py +++ b/pythonlib/camoufox/fingerprints.py @@ -373,16 +373,17 @@ def _build_init_script(values: Dict[str, Any]) -> str: f' if (typeof w.setScreenColorDepth === "function") w.setScreenColorDepth({scd});' ) - # Timezone (always call to trigger self-destruct) + # Timezone — only call setTimezone() when we have an explicit value. + # Without this, the C++ MaskConfig fallback (from CAMOU_CONFIG set by geoip + # in launch_options) handles timezone for both main thread and workers via + # SetNewDocument() and TimezoneManager::GetTimezone(). + # The old fallback read system TZ and poisoned RoverfoxStorageManager, + # preventing MaskConfig from ever being consulted. tz = values.get('timezone') if tz: lines.append( f' if (typeof w.setTimezone === "function") w.setTimezone({_json.dumps(tz)});' ) - else: - lines.append( - ' if (typeof w.setTimezone === "function") w.setTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone);' - ) # WebRTC IP ip = values.get('webrtcIP')