Skip to content
Merged
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
9 changes: 7 additions & 2 deletions pkcs11/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ def __hash__(self):


def _CK_UTF8CHAR_to_str(data):
"""Convert CK_UTF8CHAR to string."""
return data.rstrip(b"\0").decode("utf-8").rstrip()
"""
Convert CK_UTF8CHAR to string.

Substitutes invalid bytes with the replacement character to make usage more
robust with non-compliant tokens.
"""
return data.rstrip(b"\0").decode("utf-8", errors="replace").rstrip()


def _CK_VERSION_to_tuple(data):
Expand Down
Loading