desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx | 16 ++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
New commits: commit 59340251fa4c403c0659e0016ff1e606b829c669 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Jul 21 16:30:46 2025 +0200 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Tue Jul 22 23:45:29 2025 +0200 tdf#159775: restore filename from URL on redirection Some github release URLs, like https://github.com/hanya/MRI/releases/download/v1.3.5/MRI-1.3.5.oxt get redirected to something like https://release-assets.githubusercontent.com/github-production-release-asset/3265966/eff2c80e-138d-4b06-8139-e433f4672379?... of which, 'eff2c80e-138d-4b06-8139-e433f4672379' is used as ucbhelper::Content's title. That is used to construct local filename in UpdateInstallDialog::Thread::download. Later in PackageRegistryImpl::bindPackage, the extension of the file will be used to detect the mediatype; if failed, operation will abort. Detect this situation, and restore the filename from URL. Change-Id: Ib95189ff35e07fd01c95f87827c6f620ebfe2fe1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188114 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit b729b0bb677bd2b82492b45806ed3ddd91d2234f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188188 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx index 0e97be68ebc1..24e480b326c9 100644 --- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx @@ -48,6 +48,7 @@ #include <dp_misc.h> #include "dp_gui_extensioncmdqueue.hxx" #include <ucbhelper/content.hxx> +#include <tools/urlobj.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/ref.hxx> #include <salhelper/thread.hxx> @@ -559,7 +560,20 @@ bool UpdateInstallDialog::Thread::download(OUString const & sDownloadURL, Update ::ucbhelper::Content sourceContent; (void)dp_misc::create_ucb_content(&sourceContent, sDownloadURL, m_updateCmdEnv); - const OUString sTitle( StrTitle::getTitle( sourceContent ) ); + OUString sTitle(StrTitle::getTitle(sourceContent)); + if (sTitle.indexOf('.') < 0) + { + // The title could be changed due to redirection (seen with github URLs, which arrive + // something like 'eff2c80e-138d-4b06-8139-e433f4672379'). This will create problems in + // PackageRegistryImpl::bindPackage, where extension will be required to get mediatype. + // Try to restore the filename with extension from the URL. + // TODO: could also use Content-Disposition (RFC 6266), where the filename is provided. + INetURLObject aUrl(sDownloadURL); + aUrl.removeFinalSlash(); + OUString newTitle = aUrl.GetLastName(INetURLObject::DecodeMechanism::WithCharset); + if (newTitle.indexOf('.') >= 0) + sTitle = newTitle; + } destFolderContent.transferContent( sourceContent, ::ucbhelper::InsertOperation::Copy,