From a72bf83befad4f9d80111cffbdfcf28f8df2a0c8 Mon Sep 17 00:00:00 2001 From: Karthik Godha Date: Sat, 28 Feb 2026 19:30:12 +0530 Subject: [PATCH] tdf#171084: Invalid filename used for external references bug-document: forum-mso-en4-109719.xls Change-Id: I52bac59b9930f65f43dd9b354309d6ce57fcddd6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200692 Reviewed-by: Michael Stahl Tested-by: Jenkins CollaboraOffice (cherry picked from commit a8a694f065d26039457fda5a1e5de1aae1daaf7a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202127 Tested-by: Jenkins Reviewed-by: Karthik Godha --- sc/source/core/data/global2.cxx | 4 ++++ sc/source/filter/excel/xecontent.cxx | 3 +++ 2 files changed, 7 insertions(+) diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx index 4a9237a38f9f..c86ecee0abb1 100644 --- a/sc/source/core/data/global2.cxx +++ b/sc/source/core/data/global2.cxx @@ -319,6 +319,10 @@ OUString ScGlobal::GetAbsDocName( const OUString& rFileName, aAbsName = aObj.GetMainURL(INetURLObject::DecodeMechanism::NONE); } } + + if (aAbsName.endsWith("/")) + aAbsName = aAbsName.copy(0, aAbsName.getLength() - 1); + return aAbsName; } diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index cfc2d2c80ddf..0404740d1b0c 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -483,6 +483,9 @@ OUString XclExpHyperlink::BuildFileName( INetURLObject aURLObject( rUrl ); OUString aDosName(bEncoded ? aURLObject.GetMainURL(INetURLObject::DecodeMechanism::ToIUri) : aURLObject.getFSysPath(FSysStyle::Dos)); + if (aDosName.endsWith("/")) + aDosName = aDosName.copy(0, aDosName.getLength() - 1); + rnLevel = 0; rbRel = rRoot.IsRelUrl();