Skip to content

Commit

Permalink
Sanitize comments: prevent UnicodeDecodeError in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
hakavlad committed Feb 3, 2024
1 parent 4b100f8 commit d63d635
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tird/tird.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ def get_comments_bytes() -> bytes:
f'{BOL}[10] Comments (optional, up to {COMMENTS_SIZE} B):{RES} ')

if comments != '':
# Sanitize comments: prevent UnicodeDecodeError in some cases
comments = comments.encode()[:COMMENTS_SIZE].decode('utf-8', 'ignore')

comments_bytes: bytes = comments.encode()
comments_bytes = b''.join([
comments_bytes,
Expand Down

0 comments on commit d63d635

Please sign in to comment.