Skip to content

Commit b5935f0

Browse files
grucinGrzegorz Ruciński
andauthored
Remove coding system from UserComment sequence only if it is valid (#147)
Co-authored-by: Grzegorz Ruciński <grucin@mobile4.pro>
1 parent d863b62 commit b5935f0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

exifread/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def make_string_uc(seq) -> str:
4545
First 8 bytes gives coding system e.g. ASCII vs. JIS vs Unicode.
4646
"""
4747
if not isinstance(seq, str):
48-
seq = seq[8:]
48+
# Remove code from sequence only if it is valid
49+
if make_string(seq[:8]).upper() in ('ASCII', 'UNICODE', 'JIS', ''):
50+
seq = seq[8:]
4951
# Of course, this is only correct if ASCII, and the standard explicitly
5052
# allows JIS and Unicode.
5153
return make_string(seq)

0 commit comments

Comments
 (0)