sfx2/source/doc/objmisc.cxx             |    3 +++
 xmlsecurity/qa/unit/signing/signing.cxx |   30 ++++++------------------------
 2 files changed, 9 insertions(+), 24 deletions(-)

New commits:
commit 929d46bbf42aefc1f6cf046c2b9cf3d7c4e1efc5
Author:     Jan-Marek Glogowski <[email protected]>
AuthorDate: Thu Mar 12 18:07:48 2020 +0100
Commit:     Thorsten Behrens <[email protected]>
CommitDate: Fri Mar 13 00:37:46 2020 +0100

    tdf#42316 always evaluate macro signatures on load
    
    As already stated in the comments of the signing unit tests,
    disabling macro security will not only ignore the signatures, but
    actually drop the macro signature, as these are never evaluated
    and as a result can't be restored for the new document.
    
    Change-Id: Ie41a9e72d3367c2eed58a52387bb67d8c41abff3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90435
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <[email protected]>

diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 0f155cc7e4f9..43a5f5b10800 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -928,6 +928,9 @@ void SfxObjectShell::BreakMacroSign_Impl( bool 
bBreakMacroSign )
 
 void SfxObjectShell::CheckSecurityOnLoading_Impl()
 {
+    // make sure LO evaluates the macro signatures, so it can be preserved
+    GetScriptingSignatureState();
+
     uno::Reference< task::XInteractionHandler > xInteraction;
     if ( GetMedium() )
         xInteraction = GetMedium()->GetInteractionHandler();
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx 
b/xmlsecurity/qa/unit/signing/signing.cxx
index 5a3cdb55f608..2609ae91cd24 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -1009,15 +1009,9 @@ CPPUNIT_TEST_FIXTURE(SigningTest, 
testPreserveMacroTemplateSignature12_ODF)
                    ODFVER_012_TEXT);
 
     // create new document from template
-    // we can't use createDoc / MacrosTest::loadFromDesktop, because 
ALWAYS_EXECUTE_NO_WARN
-    // won't verify the signature for templates, so the resulting document 
won't be able to
-    // preserve the templates signature.
     mxComponent->dispose();
-    mxComponent = mxDesktop->loadComponentFromURL(
-        aURL, "_default", 0,
-        comphelper::InitPropertySequence(
-            { { "MacroExecutionMode",
-                
uno::Any(document::MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN) } }));
+    mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0,
+                                                  
uno::Sequence<beans::PropertyValue>(0));
     CPPUNIT_ASSERT_MESSAGE(OUStringToOString(sLoadMessage, 
RTL_TEXTENCODING_UTF8).getStr(),
                            mxComponent.is());
 
@@ -1119,15 +1113,9 @@ CPPUNIT_TEST_FIXTURE(SigningTest, 
testDropMacroTemplateSignature)
                    SignatureState::NOTVALIDATED, OUString());
 
     // create new document from template
-    // we can't use createDoc / MacrosTest::loadFromDesktop, because 
ALWAYS_EXECUTE_NO_WARN
-    // won't verify the signature for templates, so the resulting document 
won't be able to
-    // preserve the templates signature.
     mxComponent->dispose();
-    mxComponent = mxDesktop->loadComponentFromURL(
-        aURL, "_default", 0,
-        comphelper::InitPropertySequence(
-            { { "MacroExecutionMode",
-                
uno::Any(document::MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN) } }));
+    mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0,
+                                                  
uno::Sequence<beans::PropertyValue>(0));
     CPPUNIT_ASSERT_MESSAGE(OUStringToOString(sLoadMessage, 
RTL_TEXTENCODING_UTF8).getStr(),
                            mxComponent.is());
 
@@ -1252,15 +1240,9 @@ CPPUNIT_TEST_FIXTURE(SigningTest, 
testPreserveMacroTemplateSignature10)
                    SignatureState::NOTVALIDATED, OUString());
 
     // create new document from template
-    // we can't use createDoc / MacrosTest::loadFromDesktop, because 
ALWAYS_EXECUTE_NO_WARN
-    // won't verify the signature for templates, so the resulting document 
won't be able to
-    // preserve the templates signature.
     mxComponent->dispose();
-    mxComponent = mxDesktop->loadComponentFromURL(
-        aURL, "_default", 0,
-        comphelper::InitPropertySequence(
-            { { "MacroExecutionMode",
-                
uno::Any(document::MacroExecMode::FROM_LIST_AND_SIGNED_NO_WARN) } }));
+    mxComponent = mxDesktop->loadComponentFromURL(aURL, "_default", 0,
+                                                  
uno::Sequence<beans::PropertyValue>(0));
     CPPUNIT_ASSERT_MESSAGE(OUStringToOString(sLoadMessage, 
RTL_TEXTENCODING_UTF8).getStr(),
                            mxComponent.is());
 
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to