sc/source/filter/excel/excel.cxx |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 1e1072afa3726266f83d7ef8895ed406580a3450
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Feb 16 23:56:52 2024 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Sat Feb 17 03:54:24 2024 +0100

    sc: Handle xls documents with unknown DRM encryption better
    
    If we can't decrypt the document, don't set the SotStorage to
    an empty SvRef. It is possible the document contains a "fallback"
    un-encrypted document, which we can show. This is typical for some
    Excel add-ons, which encrypt the document, but also add a part
    that is un-encrypted to write the instructions on how to get the
    add-on.
    
    Change-Id: I6079786b1d0dce3a819a70e057699d0a461a5be5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163511
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sc/source/filter/excel/excel.cxx b/sc/source/filter/excel/excel.cxx
index 1d68152127d0..3542208eb174 100644
--- a/sc/source/filter/excel/excel.cxx
+++ b/sc/source/filter/excel/excel.cxx
@@ -183,7 +183,9 @@ ErrCode ScFormatFilterPluginImpl::ScImportExcel( SfxMedium& 
rMedium, ScDocument*
         tools::SvRef<SotStorageStream> xDRMStrm = 
ScfTools::OpenStorageStreamRead(xRootStrg, " DRMContent");
         if (xDRMStrm.is())
         {
-            xRootStrg = lcl_DRMDecrypt(rMedium, xRootStrg, aNewStorageStrm);
+            auto pDecryptedStorage = lcl_DRMDecrypt(rMedium, xRootStrg, 
aNewStorageStrm);
+            if (pDecryptedStorage)
+                xRootStrg = pDecryptedStorage;
         }
 
         // try to open the "Book" stream

Reply via email to