Files
odfstudio/sd/source/filter
Andras Timar b2828755fc cool#16022 pass PDF password through to the version downgrade on import
Opening a password-protected PDF that is newer than version 1.6
failed with "loadComponentFromURL returned an empty reference":
the correct password was rejected. Online exports encrypted PDFs
as 1.7 by default, so this hit every password-protected PDF it
produced.

On import a too-new PDF is downgraded to 1.6 by
convertToHighestSupported, which for an encrypted stream has to
decrypt it (saveWithVersion with security removed). That needs
the password, but the Draw import path (SdPdfFilter::Import ->
ImportPDFUnloaded -> createBinaryDataContainer) passed neither
a password nor an interaction handler, so the downgrade bailed
out ("no Int handler for pass"), returned an empty container and
the load failed.

Thread the password already collected during type detection
(medium SID_PASSWORD), plus the interaction handler, from
SdPdfFilter down to convertToHighestSupported and pre-seed its
password loop with it. Passing the known password matters: the
kit treats a second password callback as a wrong-password retry
and aborts, so re-prompting via the handler alone would turn the
correct password into a spurious rejection.

Add a unit test covering ImportPDFUnloaded on an encrypted 1.7 PDF:
it yields no pages without a password and one page with the right one.

Fixes https://github.com/CollaboraOnline/online/issues/16022

Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I6d605c3495a6af2f1763fda2b8f57a058f70c402
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/7711
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 1f96e3d85a55bc1d6cf437fc96f729b44dbf8ce2)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208625
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
2026-07-27 15:47:20 +02:00
..
2026-03-04 11:29:39 +01:00