sc/source/filter/excel/xestream.cxx |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit 30e2c72cf63ba6fae8bd2948518169e7d5159e4c
Author:     Karthik Godha <[email protected]>
AuthorDate: Sat Jan 10 17:15:47 2026 +0530
Commit:     Michael Stahl <[email protected]>
CommitDate: Mon Jan 12 12:58:12 2026 +0100

    tdf#170287: XLS->XLSX Limit font-name length to 31
    
    Change-Id: I4bb731afaf2f741181ee525af473d6bf4dfac5c2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196963
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sc/source/filter/excel/xestream.cxx 
b/sc/source/filter/excel/xestream.cxx
index 2c99632b5d34..61bb26ca0b31 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -902,7 +902,22 @@ sax_fastparser::FSHelperPtr XclXmlUtils::WriteFontData( 
sax_fastparser::FSHelper
     }
 
     assert(!rFontData.maName.isEmpty() && "Font Name can't be empty");
-    pStream->singleElement(nFontId, XML_val, rFontData.maName);
+
+    constexpr sal_Int32 MAX_FONT_LENGTH = 31;
+    OUString sFont = rFontData.maName;
+    if (sFont.getLength() > MAX_FONT_LENGTH)
+    {
+        sFont = sFont.copy(0, MAX_FONT_LENGTH);
+        // Truncate till last semi-colon
+        if (rFontData.maName[MAX_FONT_LENGTH] != ';')
+        {
+            sal_Int32 nIndex = sFont.lastIndexOf(';');
+            if (nIndex != -1)
+                sFont = sFont.copy(0, nIndex);
+        }
+    }
+
+    pStream->singleElement(nFontId, XML_val, sFont);
     pStream->singleElement(XML_family, XML_val, OString::number(  
rFontData.mnFamily ));
     if (rFontData.mnCharSet != 0)
         pStream->singleElement(XML_charset, XML_val, 
OString::number(rFontData.mnCharSet));

Reply via email to