sc/source/filter/excel/xelink.cxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit ae2114a45f7559897550b8a2997a86f640c3a3ad
Author:     Karthik Godha <[email protected]>
AuthorDate: Sun Feb 1 16:55:56 2026 +0530
Commit:     Michael Stahl <[email protected]>
CommitDate: Thu Feb 12 17:42:03 2026 +0100

    XLSX: Handle invalid SheetName in ExternalLink
    
    bug-document: forum-mso-de-79957.xls
    Change-Id: I62aee260a64bcf512bf92f985bdbe796796b52a7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198511
    Reviewed-by: Michael Stahl <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    (cherry picked from commit 7f7ac179e8f5194a1e8da34737a21ea1fbe65409)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199253

diff --git a/sc/source/filter/excel/xelink.cxx 
b/sc/source/filter/excel/xelink.cxx
index f0f8c22e4e05..e47ab65f4c9e 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -1688,8 +1688,12 @@ void XclExpSupbook::SaveXml( XclExpXmlStream& rStrm )
         pExternalLink->startElement(XML_sheetNames);
         for (size_t nPos = 0, nSize = maXctList.GetSize(); nPos < nSize; 
++nPos)
         {
-            pExternalLink->singleElement(XML_sheetName,
-                XML_val, 
XclXmlUtils::ToOString(maXctList.GetRecord(nPos)->GetTabName()));
+            OString sSheetName = 
XclXmlUtils::ToOString(maXctList.GetRecord(nPos)->GetTabName());
+            // Sometimes `ReadUniString` could result in a garbage string
+            // Guess whether the SheetName is valid by checking if it contains 
'?'
+            if (sSheetName.indexOf("?") != -1)
+                sSheetName = "Invalid_Sheet_Name_" + 
OString::number(sSheetName.getLength());
+            pExternalLink->singleElement(XML_sheetName, XML_val, sSheetName);
         }
         pExternalLink->endElement( XML_sheetNames);
 

Reply via email to