koodaamo / tnefparse

a TNEF decoding library written in python, without external dependencies
GNU Lesser General Public License v3.0
49 stars 37 forks source link

Add optimisation from pull #15 and fix long_filename() function #17

Closed sorinsrn7 closed 6 years ago

sorinsrn7 commented 6 years ago

The actual problem is that tnefparse can't get the full name of the attachments from inside.

Without the fix:

>>> import tnefparse
>>> for attachment in tnefparse.tnef.TNEF(open("/tmp/winmail.dat", "rb").read()).attachments:
...     print "%s -> %s" % (attachment.name, attachment.long_filename())
... 
No handlers could be found for logger "tnef-decode"
299BKP~1.PDF -> 299BKP~1.PDF
NPK_TE~1.MSI -> NPK_TE~1.MSI
SIA451.01S -> SIA451.01S
image001.png -> image001.png

With the fix:

>>> for attachment in tnefparse.tnef.TNEF(open("/tmp/winmail.dat", "rb").read()).attachments:
...     print "%s -> %s" % (attachment.name, attachment.long_filename())
... 
299BKP~1.PDF -> 299 BKP 211 Angebotsformular Baumeister H1.pdf
NPK_TE~1.MSI -> NPK_Texte.MSIA
SIA451.01S -> SIA451.01S
image001.png -> image001.png
petri commented 6 years ago

I had already merged #15 before checking this PR so just added long_filename fix manually. So the changes you suggested are now merged. Thanks for your contribution. Please reopen & resubmit or file an issue if there's still something missing.