From 3ab720a94876cfe7d75f8e440a9d6a6a0e07d4ec Mon Sep 17 00:00:00 2001 From: Atiqur Rahman Date: Wed, 29 Jul 2026 11:51:03 +0600 Subject: [PATCH] fix(network): prevent UnicodeDecodeError in Request.post_data for non-UTF8 bodies (fixes #3098) --- playwright/_impl/_network.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/playwright/_impl/_network.py b/playwright/_impl/_network.py index 3e9685e6e..558a9f736 100644 --- a/playwright/_impl/_network.py +++ b/playwright/_impl/_network.py @@ -209,10 +209,10 @@ async def sizes(self) -> RequestSizes: def post_data(self) -> Optional[str]: data = self._fallback_overrides.post_data_buffer if data: - return data.decode() + return data.decode(errors="replace") base64_post_data = self._initializer.get("postData") if base64_post_data is not None: - return base64.b64decode(base64_post_data).decode() + return base64.b64decode(base64_post_data).decode(errors="replace") return None @property