From f5def983004a85d562f36eaceee2ab724cb24fcc Mon Sep 17 00:00:00 2001 From: vihangatheturtle <43118457+vihangatheturtle@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:57:50 +0000 Subject: [PATCH 1/2] Update server.py --- pythonlib/camoufox/server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pythonlib/camoufox/server.py b/pythonlib/camoufox/server.py index 2cc6225..1103aac 100644 --- a/pythonlib/camoufox/server.py +++ b/pythonlib/camoufox/server.py @@ -2,6 +2,7 @@ import subprocess from pathlib import Path from typing import Any, Dict, NoReturn, Tuple, Union +import base64 import orjson from playwright._impl._driver import compute_driver_executable @@ -47,7 +48,7 @@ def launch_server(**kwargs) -> NoReturn: config = launch_options(**kwargs) nodejs = get_nodejs() - data = orjson.dumps(to_camel_case_dict(config)).decode() + data = orjson.dumps(to_camel_case_dict(config)) process = subprocess.Popen( # nosec [ @@ -60,7 +61,7 @@ def launch_server(**kwargs) -> NoReturn: ) # Write data to stdin and close the stream if process.stdin: - process.stdin.write(data) + process.stdin.write(base64.b64encode(data).decode()) process.stdin.close() # Wait forever From 133afbcdea8a3a723a4fd490cb853a01d32df97f Mon Sep 17 00:00:00 2001 From: vihangatheturtle <43118457+vihangatheturtle@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:58:18 +0000 Subject: [PATCH 2/2] Update launchServer.js --- pythonlib/camoufox/launchServer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pythonlib/camoufox/launchServer.js b/pythonlib/camoufox/launchServer.js index 90a0aa2..ea56e79 100644 --- a/pythonlib/camoufox/launchServer.js +++ b/pythonlib/camoufox/launchServer.js @@ -13,7 +13,7 @@ function collectData() { }); process.stdin.on('end', () => { - resolve(JSON.parse(data)); + resolve(JSON.parse(Buffer.from(data, "base64").toString())); }); }); } @@ -37,4 +37,4 @@ collectData().then((options) => { }).catch((error) => { console.error('Error collecting data:', error.message); process.exit(1); // Exit with error code -}); \ No newline at end of file +});