sfx2/source/doc/objmisc.cxx |    6 ++++++
 sfx2/source/doc/objserv.cxx |   10 ++++++++++
 sfx2/source/doc/objstor.cxx |    2 ++
 3 files changed, 18 insertions(+)

New commits:
commit e79f03530bc8af241624fd723116d8c883cbcaff
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Jul 4 12:10:29 2024 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Wed Jul 10 11:50:31 2024 +0200

    sfx2: fix signature infobar being shown for every repaired document
    
    (regression from commit 8b333575ee680664fa3d83249ccec90881754ad7)
    
    So it should only be set if the state is still UNKNOWN.  But
    SfxObjectShell::ImplGetSignatureState() is called before the repair
    dialog is shown, so make sure that the second import (with
    RepairPackage) finds both members as SignatureState::UNKOWN.
    
    Change-Id: Ic914016dde6425a4d95fba7f6f66411305553930
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169989
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 8d869b5fe47842df52965804db87db0941f4f2a0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169997
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit 127194ebbcbf644148fee81773babaf23eab78d8)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170028
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 9ef1469687b3..a6610661f676 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -953,6 +953,12 @@ void SfxObjectShell::BreakMacroSign_Impl( bool 
bBreakMacroSign )
 
 void SfxObjectShell::CheckSecurityOnLoading_Impl()
 {
+    if (GetErrorCode() == ERRCODE_IO_BROKENPACKAGE)
+    {   // safety first: don't run any macros from broken package.
+        pImpl->aMacroMode.disallowMacroExecution();
+        return; // do not get signature status - needs to be done after 
RepairPackage
+    }
+
     // make sure LO evaluates the macro signatures, so it can be preserved
     GetScriptingSignatureState();
 
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 4cfdf56e9037..5fb379e8f374 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1902,19 +1902,22 @@ SignatureState SfxObjectShell::ImplGetSignatureState( 
bool bScriptingContent )
 {
     SignatureState* pState = bScriptingContent ? 
&pImpl->nScriptingSignatureState : &pImpl->nDocumentSignatureState;
 
-    // repaired package cannot be trusted
-    SfxBoolItem const*const 
pRepairItem{GetMedium()->GetItemSet().GetItem(SID_REPAIRPACKAGE, false)};
-    if (pRepairItem && pRepairItem->GetValue())
-    {
-        *pState = SignatureState::BROKEN;
-    }
-
     if ( *pState == SignatureState::UNKNOWN )
     {
         *pState = SignatureState::NOSIGNATURES;
 
         uno::Sequence< security::DocumentSignatureInformation > aInfos = 
GetDocumentSignatureInformation( bScriptingContent );
         *pState = DocumentSignatures::getSignatureState(aInfos);
+
+        // repaired package cannot be trusted
+        if (*pState != SignatureState::NOSIGNATURES)
+        {
+            SfxBoolItem const*const 
pRepairItem{GetMedium()->GetItemSet().GetItem(SID_REPAIRPACKAGE, false)};
+            if (pRepairItem && pRepairItem->GetValue())
+            {
+                *pState = SignatureState::BROKEN;
+            }
+        }
     }
 
     if ( *pState == SignatureState::OK || *pState == 
SignatureState::NOTVALIDATED
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index a6aaee75ea87..4cf78b262903 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -401,6 +401,8 @@ void SfxObjectShell::PrepareSecondTryLoad_Impl()
     // only for internal use
     pImpl->m_xDocStorage.clear();
     pImpl->mxObjectContainer.reset();
+    pImpl->nDocumentSignatureState = SignatureState::UNKNOWN;
+    pImpl->nScriptingSignatureState = SignatureState::UNKNOWN;
     pImpl->m_bIsInit = false;
     ResetError();
 }
commit 8c4007f1550699ac88486d2c6e4b339aca2d2171
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Jul 2 13:24:38 2024 +0200
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Wed Jul 10 11:50:27 2024 +0200

    sfx2: SfxObjectShell should not trust any signature on repaired package
    
    Change-Id: I0317f80989e9dabd23e88e3caab26ede3fb5bd56
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169883
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 8b333575ee680664fa3d83249ccec90881754ad7)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169930
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit 05b9e388448b1c8c10b18c22898c4725dd176fed)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169952
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
    Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index de2e01ff8d76..4cfdf56e9037 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1902,6 +1902,13 @@ SignatureState SfxObjectShell::ImplGetSignatureState( 
bool bScriptingContent )
 {
     SignatureState* pState = bScriptingContent ? 
&pImpl->nScriptingSignatureState : &pImpl->nDocumentSignatureState;
 
+    // repaired package cannot be trusted
+    SfxBoolItem const*const 
pRepairItem{GetMedium()->GetItemSet().GetItem(SID_REPAIRPACKAGE, false)};
+    if (pRepairItem && pRepairItem->GetValue())
+    {
+        *pState = SignatureState::BROKEN;
+    }
+
     if ( *pState == SignatureState::UNKNOWN )
     {
         *pState = SignatureState::NOSIGNATURES;

Reply via email to