HiraokaHyperTools / msgreader

40 stars 9 forks source link

Some .msg attachments cannot be opened with MS Outlook #22

Closed GTCrais closed 3 years ago

GTCrais commented 3 years ago

Example scenario:

To check your permissions, right-click the file folder, then click Properties.


- these attachments, however, **can** be parsed using `msgreader`, and their attachments (PDFs etc.) can be saved to disk, and opened in PDF viewer etc -- in our Example scenario, `FooDocument.pdf` and `BarDocument.pdf` would be normally saved and usable.

This is **not** a permission issue, and the file is **not** already open. 

This issue also does not happen with all emails which have .msg attachments, only some. Link to an example email provided at the bottom of the issue description.

#### After further testing:
- v1.9.0 - no issue
- v1.10.0 - no issue
- v1.11.0 - no issue
- **v1.12.0-alpha.1 - issue appears**

https://github.com/HiraokaHyperTools/msgreader/commit/81edcca6a147ebfcecd97b36304852c8cbb18926 - this must be the commit that started causing this

### Here's an example email whose .msg attachment breaks - [download](https://bit.ly/3c0MfN6)
kenjiuno commented 3 years ago

Thanks for reporting this. I could reproduce the open error problem by Outlook 2013 (using saved inner msg).

I wrote a flow that is useful to discuss about broken part of msgreader. This will be Case 2. Maybe bug in **structure handling**.

how-to

kenjiuno commented 3 years ago

No, this is bug of Burner mentioned at https://github.com/HiraokaHyperTools/msgreader/commit/81edcca6a147ebfcecd97b36304852c8cbb18926

This awful mistake https://github.com/HiraokaHyperTools/msgreader/commit/79bb367a3ddd10c222e80a2aacb8c728f1eaa078 was fixed right away on 1.13.0-alpha.1

I'll search CFBF validation tool for detecting this kind of cases.

kenjiuno commented 3 years ago

Ok I have written simple Win32 ValidateCompoundFile.exe https://github.com/HiraokaHyperTools/ValidateCompoundFile/blob/master/main.cpp

H:\Proj\msgreader> tools\ValidateCompoundFile.exe "X:\msgreader\22\BROKEN Test child email.msg"
StgOpenStorageEx returned 0x80030109

H:\Proj\msgreader> tools\ValidateCompoundFile.exe "X:\msgreader\22\Test child email.msg"
StgOpenStorageEx returned 0x00000000

StgOpenStorageEx function will be usable to detect broken archives generated by v1.12.0-alpha1.

%ERRORLEVEL% is returned like generic Unix tool. Usage: ValidateCompoundFile.exe a.msg && echo OK || echo ERROR

And included tests can be run by yarn command.

kenjiuno commented 3 years ago

I'll publish 1.13.0 in some days if there is no more further side effect (or bug report).

GTCrais commented 3 years ago

Thanks for fixing this.

Unfortunately, this fix introduced another bug - https://github.com/HiraokaHyperTools/msgreader/issues/23

Update: This fix did not introduce the https://github.com/HiraokaHyperTools/msgreader/issues/23 bug. I'll run more tests, but I think this issue (#22) can be closed.

GTCrais commented 3 years ago

After thorough testing, I can confirm this has been fixed. Closing the issue.

Thanks for the fix!