Skip to content

Commit

Permalink
Remove coding system from UserComment sequence only if it is valid (#147
Browse files Browse the repository at this point in the history
)

Co-authored-by: Grzegorz Ruciński <[email protected]>
  • Loading branch information
grucin and Grzegorz Ruciński authored Apr 22, 2021
1 parent d863b62 commit b5935f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion exifread/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def make_string_uc(seq) -> str:
First 8 bytes gives coding system e.g. ASCII vs. JIS vs Unicode.
"""
if not isinstance(seq, str):
seq = seq[8:]
# Remove code from sequence only if it is valid
if make_string(seq[:8]).upper() in ('ASCII', 'UNICODE', 'JIS', ''):
seq = seq[8:]
# Of course, this is only correct if ASCII, and the standard explicitly
# allows JIS and Unicode.
return make_string(seq)
Expand Down

0 comments on commit b5935f0

Please sign in to comment.