office: retain EncryptionInfo part for password-protected detection
- Commit
0cd1362765cbe6ad0f6cf9b28bbde6a4ea4e21e7- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-06 18:24 UTC (29 days ago)
- Parents
2c4b4f0
OoxmlPackage.read dropped the extensionless EncryptionInfo entry, so OoxmlImporter's password-protected guard never fired and such files fell through to 'unrecognized'. Retain the entry as text like other XML parts. (cherry picked from commit 0f29c064439dfa7708c8691021948cd46000f766)
Diff
office/src/main/java/com/vayunmathur/office/odf/OoxmlPackage.kt
diff --git a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPackage.kt b/office/src/main/java/com/vayunmathur/office/odf/OoxmlPackage.ktindex 8c20751e2b..cce4646a11 100644--- a/office/src/main/java/com/vayunmathur/office/odf/OoxmlPackage.kt+++ b/office/src/main/java/com/vayunmathur/office/odf/OoxmlPackage.kt@@ -119,9 +119,11 @@ internal class OoxmlPackage( if (!e.isDirectory) { val ext = n.substringAfterLast('.', "").lowercase() when {- n.endsWith(".xml") || n.endsWith(".rels") ->+ n.endsWith(".xml") || n.endsWith(".rels") || n == "EncryptionInfo" -> // Strip a leading UTF-8 BOM (Word writes one on several parts); // a retained U+FEFF makes the pull parser reject the XML prolog.+ // "EncryptionInfo" (no extension) is retained so OoxmlImporter+ // can report password-protected files instead of "unrecognized". entries[n] = zip.readBytes().toString(Charsets.UTF_8).removePrefix("\uFEFF") ext in MEDIA_EXTS -> media[n] = zip.readBytes() }