Skip to content

Commit 552732b

Browse files
author
Dominikus Gierlach
committed
Remove unrelated string decoding change
1 parent 684d7cb commit 552732b

File tree

3 files changed

+3
-28
lines changed

3 files changed

+3
-28
lines changed

pkcs11/types.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
from binascii import hexlify
88
from functools import cached_property
99

10-
import chardet
11-
1210
from pkcs11 import CancelStrategy
1311
from pkcs11.constants import (
1412
Attribute,
@@ -43,17 +41,8 @@ def __hash__(self):
4341

4442

4543
def _CK_UTF8CHAR_to_str(data):
46-
"""Convert _CK_UTF8CHAR_to_str to string using chardet for encoding detection."""
47-
cleaned_data = data.rstrip(b"\0")
48-
49-
detected_encoding = chardet.detect(cleaned_data)
50-
encoding = detected_encoding["encoding"] or "utf-8"
51-
52-
try:
53-
return cleaned_data.decode(encoding).rstrip()
54-
except UnicodeDecodeError:
55-
# If decoding fails, try utf-8 with default error replacement character as a last resort
56-
return cleaned_data.decode("utf-8", errors="replace").rstrip()
44+
"""Convert CK_UTF8CHAR to string."""
45+
return data.rstrip(b"\0").decode("utf-8").rstrip()
5746

5847

5948
def _CK_VERSION_to_tuple(data):

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ classifiers = [
2525
]
2626
dependencies = [
2727
"asn1crypto>=1.5.1",
28-
"chardet>=5.2.0",
2928
]
3029
license = "MIT"
3130
requires-python = ">=3.9"

uv.lock

Lines changed: 1 addition & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)