[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Feb 13 09:03:16 UTC 2019


 sc/source/core/tool/compiler.cxx |   26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

New commits:
commit 99b0a3702d9c04c68d33adb9fbf1fd289618cc89
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Tue Jan 29 15:25:52 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Feb 13 10:02:47 2019 +0100

    Resolves: tdf#93951 set remainder as bad string if not parsed as valid
    
    Change-Id: Ieb9fa5e9cd2d5919a36fbe65ced107eab33c72e2
    Reviewed-on: https://gerrit.libreoffice.org/67090
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 7d6f30d04c51088b26815c241a7473c48822c6c3)
    Reviewed-on: https://gerrit.libreoffice.org/67115
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index eef51bbeecff..7ed3845f967e 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2630,6 +2630,7 @@ Label_MaskStateMachine:
     }
     if ( bi18n )
     {
+        const sal_Int32 nOldSrcPos = nSrcPos;
         nSrcPos = nSrcPos + nSpaces;
         OUStringBuffer aSymbol;
         mnRangeOpPosInSymbol = -1;
@@ -2649,11 +2650,15 @@ Label_MaskStateMachine:
                 SetError( nErr );      // parsed chars as string
             }
             if ( aRes.EndPos <= nSrcPos )
-            {   // ?!?
+            {
+                // Could not parse anything meaningful.
+                assert(!aRes.TokenType);
                 nErr = FormulaError::IllegalChar;
                 SetError( nErr );
-                nSrcPos = aFormula.getLength();
-                aSymbol.truncate();
+                // Caller has to act on an empty symbol for
+                // nSrcPos < aFormula.getLength()
+                nSrcPos = nOldSrcPos;
+                aSymbol.setLength(0);
             }
             else
             {
@@ -4117,7 +4122,22 @@ bool ScCompiler::NextNewToken( bool bInArray )
     sal_Int32 nSpaces = NextSymbol(bInArray);
 
     if (!cSymbol[0])
+    {
+        if (nSrcPos < aFormula.getLength())
+        {
+            // Nothing could be parsed, remainder as bad string.
+            // NextSymbol() must had set an error for this.
+            assert( pArr->GetCodeError() != FormulaError::NONE);
+            const OUString aBad( aFormula.copy( nSrcPos));
+            svl::SharedString aSS = pDoc->GetSharedStringPool().intern( aBad);
+            maRawToken.SetString( aSS.getData(), aSS.getDataIgnoreCase());
+            maRawToken.NewOpCode( ocBad);
+            nSrcPos = aFormula.getLength();
+            // Add bad string as last token.
+            return true;
+        }
         return false;
+    }
 
     if( nSpaces )
     {


More information about the Libreoffice-commits mailing list