Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions joppy/client_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def _request(
json=data,
files=files,
)
# Joplin's REST API always returns UTF-8, but responses may omit
# the charset from the Content-Type header. Without it requests
# falls back to charset detection and mis-decodes `response.text`,
# corrupting note bodies (mojibake). Pin it.
response.encoding = "utf-8"
LOGGER.debug(f"API: response {response.text}")
response.raise_for_status()
except requests.exceptions.HTTPError as err:
Expand Down
1 change: 1 addition & 0 deletions joppy/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ class UserData(BaseData):
is_external: Optional[bool] = None
sso_auth_code: Optional[str] = None
sso_auth_code_expire_at: Optional[datetime] = None
totp_secret: Optional[str] = None


AnyData = Union[
Expand Down
5 changes: 5 additions & 0 deletions joppy/server_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ def _request(
json=json,
headers=headers,
)
# Joplin's REST API always returns UTF-8, but the item /content
# endpoint omits the charset from the Content-Type header. Without
# it requests falls back to charset detection and mis-decodes
# `response.text`, corrupting note bodies (mojibake). Pin it.
response.encoding = "utf-8"
LOGGER.debug(f"API: response {response.text}")
response.raise_for_status()
except requests.exceptions.HTTPError as err:
Expand Down
Loading