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

New commits:
commit 7f7ac179e8f5194a1e8da34737a21ea1fbe65409
Author:     Karthik Godha <[email protected]>
AuthorDate: Sun Feb 1 16:55:56 2026 +0530
Commit:     Michael Stahl <[email protected]>
CommitDate: Fri Feb 6 13:31:43 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]>

diff --git a/sc/source/filter/excel/xelink.cxx 
b/sc/source/filter/excel/xelink.cxx
index b28d70828b85..ef6d16082269 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -1690,8 +1690,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