sdext/source/pdfimport/filterdet.cxx       |    2 +-
 sdext/source/pdfimport/wrapper/wrapper.cxx |   19 ++++++++++++-------
 2 files changed, 13 insertions(+), 8 deletions(-)

New commits:
commit 7c46138b61e1dfa9b5d649d6a797737304d225fa
Author:     Dr. David Alan Gilbert <d...@treblig.org>
AuthorDate: Thu Apr 10 21:33:32 2025 +0100
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Apr 22 04:37:56 2025 +0200

    tdf#55425, tdf#66580: sdext,pdfimport: Tame password prompts
    
    If one stage in the PDF detect asks for a password and the user
    tries and gives up, don't try asking for it again.
    After the next patch we've got another place that asks, so it can
    get annoying.
    
    Change-Id: I83f670cb452bed17443330b27b10b6a8224427af
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183993
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

diff --git a/sdext/source/pdfimport/filterdet.cxx 
b/sdext/source/pdfimport/filterdet.cxx
index 56d143d3a5a2..371d9cb56cfd 100644
--- a/sdext/source/pdfimport/filterdet.cxx
+++ b/sdext/source/pdfimport/filterdet.cxx
@@ -770,7 +770,7 @@ uno::Reference< io::XStream > getAdditionalStream( const 
OUString&
                                                                                
    RTL_TEXTENCODING_ISO_8859_1 );
                                     bAuthenticated = 
pPDFFile->setupDecryptionData( aIsoPwd );
                                 }
-                                if( ! bAuthenticated )
+                                else
                                 {
                                     uno::Reference< task::XInteractionHandler 
> xIntHdl;
                                     for( const beans::PropertyValue& rAttrib : 
rFilterData )
diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx 
b/sdext/source/pdfimport/wrapper/wrapper.cxx
index d9dd44e7c187..842cfd715d4c 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -1027,6 +1027,7 @@ bool xpdf_ImportFromFile(const OUString& rURL,
                          const uno::Reference<uno::XComponentContext>& 
xContext,
                          const OUString& rFilterOptions)
 {
+    bool bPasswordOnEntry = !rPwd.isEmpty();
     OSL_ASSERT(rSink);
 
     OUString aSysUPath;
@@ -1133,14 +1134,18 @@ bool xpdf_ImportFromFile(const OUString& rURL,
                     break;
                 }
 
-                // Must be a failure to decrypt, prompt for a password
-                bEntered = getPassword(xIHdl, aPwd, !bEntered, aDocName);
-                if (!bEntered)
+                // Must be a failure to decrypt, prompt for a password unless 
we've
+                // already got one (e.g. if the hybrid detect prompted for one)
+                if (!bPasswordOnEntry)
                 {
-                    // User cancelled password input
-                    SAL_INFO("sdext.pdfimport", "User cancelled password 
input");
-                    bRet = false;
-                    break;
+                    bEntered = getPassword(xIHdl, aPwd, !bEntered, aDocName);
+                    if (!bEntered)
+                    {
+                        // User cancelled password input
+                        SAL_INFO("sdext.pdfimport", "User cancelled password 
input");
+                        bRet = false;
+                        break;
+                    }
                 }
 
                 // user entered a password, just loop around again

Reply via email to