Skip to content

Commit

Permalink
[Fix] parse_attachment > cannot parse name
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanh Ly committed Aug 30, 2022
1 parent 43e9b5b commit cc1cf2d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions imbox/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ def parse_attachment(message_part):
# Check for split filename
s_name = name.rstrip('*').split("*")
if s_name[0] == 'filename':
# If this is a split file name - use the number after the * as an index to insert this part
if len(s_name) > 1 and s_name[1] != '':
filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value)
else:
filename_parts.insert(0,value[1:-1] if value.startswith('"') else value)
try:
# If this is a split file name - use the number after the * as an index to insert this part
if len(s_name) > 1 and s_name[1] != '':
filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value)
else:
filename_parts.insert(0,value[1:-1] if value.startswith('"') else value)
except Exception as err:
logger.debug('Parse attachment name error: %s', err)
filename_parts.insert(0, value)

if 'create-date' in name:
attachment['create-date'] = value
Expand Down

0 comments on commit cc1cf2d

Please sign in to comment.