Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypted File raises FileFormatError: Unrecognized file format, using Sensitivity Label #78

Open
philmae opened this issue May 18, 2023 · 2 comments

Comments

@philmae
Copy link

philmae commented May 18, 2023

I have a file protected with a company Sensitivity Label encrypted and am trying to open it, but get an error Unrecognized file format.
image

import msoffcrypto
protected = './protected.xlsx'
unprotected = './unprotected.xlsx'

with open(protected, 'rb') as f:
   ms_file = OfficeFile(f)
   print(ms_file)

And I get
FileFormatError: Unrecognized file format

Also, when checking .is_encrypted(), the file gives the same issue.

with open(protected, 'rb') as f:
   ms_file = OfficeFile(f).is_encrypted()
   print(ms_file)

The file is working and if I use Unencrypted reads fine. The file is not password protected, but just uses the sensitivity label as encryption.

I expected that is_encrypted should at least say True, and not just fail completely.
Not sure if the current implementation can even open these files with a sensitivity flag, even if you have the key

@nolze
Copy link
Owner

nolze commented May 19, 2023

Thank you for reporting! This is an interesting case and I hope to investigate it.
A problem, however, is that I don't have access to the Sensitivity Label feature on my devices.
I would appreciate it if you could send me an encrypted (empty) sample document or create a pull request for a fix.

@philmae
Copy link
Author

philmae commented Aug 13, 2024

Book1.xlsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants