Skip to content

Commit

Permalink
handle UnicodeDecodeError on non-utf-8 check_website
Browse files Browse the repository at this point in the history
  • Loading branch information
monosans committed Mar 6, 2025
1 parent c9bd280 commit 6a6e05e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion proxy_scraper_checker/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def check(self, *, settings: Settings) -> None:
self.exit_ip = parse_ipv4(orjson.loads(content)["origin"])
elif settings.check_website_type == CheckWebsiteType.PLAIN_IP:
self.exit_ip = parse_ipv4(
content.decode(response.get_encoding(), errors="replace")
content.decode(response.get_encoding())
)
else:
self.exit_ip = None
Expand Down
4 changes: 3 additions & 1 deletion proxy_scraper_checker/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ async def _get_check_website_type_and_real_ip(
except orjson.JSONDecodeError:
try:
return CheckWebsiteType.PLAIN_IP, parse_ipv4(
content.decode(response.get_encoding(), errors="replace")
content.decode(response.get_encoding())
)
except UnicodeDecodeError:
_logger.error("Error when decoding check_website response as utf-8")
except ValueError:
pass
else:
Expand Down

0 comments on commit 6a6e05e

Please sign in to comment.