This is an automated email from the ASF dual-hosted git repository.

ardovm pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 113142d934d1985e2aad54d096f31f9603680d5f
Author: Arrigo Marchiori <[email protected]>
AuthorDate: Sun Jun 15 20:50:29 2025 +0200

    Validate brush URLs
---
 main/sw/source/core/unocore/unosett.cxx | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/main/sw/source/core/unocore/unosett.cxx 
b/main/sw/source/core/unocore/unosett.cxx
index 0bdaea8699..5d62969d6f 100644
--- a/main/sw/source/core/unocore/unosett.cxx
+++ b/main/sw/source/core/unocore/unosett.cxx
@@ -24,6 +24,9 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sw.hxx"
 
+#include <sfx2/docfile.hxx>
+#include <sfx2/frame.hxx>
+#include <sfx2/linkmgr.hxx>
 #include <svx/svxids.hrc>
 #include <editeng/memberids.hrc>
 #include <swtypes.hxx>
@@ -2097,6 +2100,31 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
                                {
                                        OUString sBrushURL;
                                        pData->aVal >>= sBrushURL;
+                                       // We could have pDoc, but not 
pDocShell, or vice-versa
+                                       SwDoc* myDoc = pDoc;
+                                       SwDocShell* myDocShell = pDocShell;
+                                       if ( myDoc && ( myDocShell == NULL ) ) {
+                                               myDocShell = 
myDoc->GetDocShell();
+                                       } else if ( ( myDoc == NULL ) && 
myDocShell ) {
+                                               myDoc = myDocShell->GetDoc();
+                                       }
+                                       if ( myDoc && myDocShell ) {
+                                               // The following access to the 
window is copied from SwDoc::UpdateLinks()
+                                               SfxMedium* pMedium = 
myDocShell->GetMedium();
+                                               SfxFrame* pFrm = pMedium ? 
pMedium->GetLoadTargetFrame() : 0;
+                                               sfx2::LinkManager& pLinkMgr = 
myDoc->GetLinkManager();
+                                               if ( !pLinkMgr.urlIsSafe( 
sBrushURL ) ) {
+                                                       Window* pDlgParent = 0;
+                                                       if ( pFrm )
+                                                               pDlgParent = 
&pFrm->GetWindow();
+                                                       if ( !pDlgParent )
+                                                               pDlgParent = 
myDocShell->GetDialogParent( pMedium );
+                                                       if ( pDlgParent )
+                                                               if ( 
!pLinkMgr.GetUserAllowsLinkUpdate( pDlgParent )) {
+                                                                       break; 
// Stop here
+                                                               }
+                                               }
+                                       }
                                        if(!pSetBrush)
                                        {
                                                const SvxBrushItem* pOrigBrush 
= aFmt.GetBrush();

Reply via email to