Skip to content

Commit

Permalink
Replace errors when decoding from content bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
perklet committed Oct 31, 2023
1 parent aff9b69 commit cb5dfc8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion curl_cffi/requests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def __init__(self, curl: Optional[Curl] = None, request: Optional[Request] = Non

@property
def text(self) -> str:
return self.content.decode(self.charset)
try:
return self.content.decode(self.charset, errors="replace")
except (UnicodeDecodeError, LookupError):
return self.content.decode("utf-8-sig")

def raise_for_status(self):
if not self.ok:
Expand Down

0 comments on commit cb5dfc8

Please sign in to comment.