From b3000d02dd7522899cc137a2b60e0f9eab0ed3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 13 Jul 2023 16:59:52 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=A4=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lookyloo/lookyloo.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index a349e1e..655a7b7 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -1443,8 +1443,14 @@ class Lookyloo(): _img.write(png) if html: - with (dirpath / '0.html').open('w') as _html: - _html.write(html) + try: + with (dirpath / '0.html').open('w') as _html: + _html.write(html) + except UnicodeEncodeError: + # NOTE: Unable to store as string, try to store as bytes instead + # Yes, it is dirty. + with (dirpath / '0.html').open('wb') as _html: + _html.write(html.encode('utf-16', 'surrogatepass')) if last_redirected_url: with (dirpath / '0.last_redirect.txt').open('w') as _redir: