Skip to content

Commit 41cc4b7

Browse files
committed
fix: correctly add newline if last body line is exactly 64 chars long
1 parent e54501a commit 41cc4b7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

age_plugin_fido2_hmac/ipc.py

+5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,16 @@ def send_command(
2121

2222
# make sure to respect the max column size
2323
max_size = 64
24+
add_trailing_newline = len(data_encoded) > 0 and (len(data_encoded) % max_size) == 0
2425
data_encoded = '\n'.join([
2526
data_encoded[i:i+max_size]
2627
for i in range(0, len(data_encoded), max_size)
2728
])
2829

30+
if add_trailing_newline:
31+
# important: if the body size is exactly the max size, a newline needs to be added
32+
data_encoded += '\n'
33+
2934
message = '-> %s%s%s\n' % (
3035
command,
3136
' %s' % (' '.join(metadata)) if len(metadata) > 0 else '',

0 commit comments

Comments
 (0)