From 4eb559f043e81a4fe61c4353479dca3323b3d0f2 Mon Sep 17 00:00:00 2001 From: daijro Date: Thu, 19 Sep 2024 16:15:14 -0500 Subject: [PATCH] pythonlib: Fix out of bounds screen values 0.1.0b4 --- .../camoufox/{browserforge.yaml => browserforge.yml} | 0 pythonlib/camoufox/fingerprints.py | 11 +++++++---- pythonlib/pyproject.toml | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) rename pythonlib/camoufox/{browserforge.yaml => browserforge.yml} (100%) diff --git a/pythonlib/camoufox/browserforge.yaml b/pythonlib/camoufox/browserforge.yml similarity index 100% rename from pythonlib/camoufox/browserforge.yaml rename to pythonlib/camoufox/browserforge.yml diff --git a/pythonlib/camoufox/fingerprints.py b/pythonlib/camoufox/fingerprints.py index 03b6414..4963936 100644 --- a/pythonlib/camoufox/fingerprints.py +++ b/pythonlib/camoufox/fingerprints.py @@ -5,13 +5,13 @@ from browserforge.fingerprints import Fingerprint, FingerprintGenerator from yaml import CLoader, load # Load the browserforge.yaml file -with open(os.path.join(os.path.dirname(__file__), 'browserforge.yaml'), 'r') as f: +with open(os.path.join(os.path.dirname(__file__), 'browserforge.yml'), 'r') as f: BROWSERFORGE_DATA = load(f, Loader=CLoader) FP_GENERATOR = FingerprintGenerator(browser='firefox', os=('linux', 'macos', 'windows')) -def _cast_to_properties(camoufox_data, cast_enum: dict, bf_dict: dict): +def _cast_to_properties(camoufox_data: dict, cast_enum: dict, bf_dict: dict) -> None: """ Casts Browserforge fingerprints to Camoufox config properties. """ @@ -26,8 +26,11 @@ def _cast_to_properties(camoufox_data, cast_enum: dict, bf_dict: dict): # If the value is a dictionary, recursively recall if isinstance(data, dict): _cast_to_properties(camoufox_data, type_key, data) - else: - camoufox_data[type_key] = data + continue + # Fix values that are out of bounds + if type_key.startswith("screen.") and isinstance(data, int) and data < 0: + data = 0 + camoufox_data[type_key] = data def from_browserforge(fingerprint: Fingerprint) -> dict: diff --git a/pythonlib/pyproject.toml b/pythonlib/pyproject.toml index 2acca10..f663153 100644 --- a/pythonlib/pyproject.toml +++ b/pythonlib/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "camoufox" -version = "0.1.0b3" +version = "0.1.0b4" description = "Wrapper around Playwright to help launch Camoufox" authors = ["daijro "] license = "MIT"