formula/source/core/api/FormulaCompiler.cxx |    2 +-
 sc/source/core/tool/compiler.cxx            |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 64f673238cf9b645a751e8f8137ca14e595a779a
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Tue Sep 6 13:48:29 2022 +0200
Commit:     Eike Rathke <er...@redhat.com>
CommitDate: Tue Sep 6 15:40:59 2022 +0200

    A ColRowName (label) is a QuotedLabel is a SingleQuoted
    
    Hence a ' is not escaped by \' but by '' doubling it.
    
    See also ODFF 5.10 Quoted Label
    
https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part4-formula/OpenDocument-v1.3-os-part4-formula.html#__RefHeading__1017950_715980110
    
    Apparently this was always wrong and even stored in files and
    never correctly read/compiled back.
    
    Change-Id: I94bdb7d1fdffe9bbd77cf443883dd76637be981b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139491
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins

diff --git a/formula/source/core/api/FormulaCompiler.cxx 
b/formula/source/core/api/FormulaCompiler.cxx
index 3f41b2196bcf..6684fd17da47 100644
--- a/formula/source/core/api/FormulaCompiler.cxx
+++ b/formula/source/core/api/FormulaCompiler.cxx
@@ -1203,7 +1203,7 @@ bool FormulaCompiler::DeQuote( OUString& rStr )
     if ( nLen > 1 && rStr[0] == '\'' && rStr[ nLen-1 ] == '\'' )
     {
         rStr = rStr.copy( 1, nLen-2 );
-        rStr = rStr.replaceAll( "\\\'", "\'" );
+        rStr = rStr.replaceAll( "''", "'" );
         return true;
     }
     return false;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index de4cb870861e..550354d6b8f4 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5357,13 +5357,13 @@ void ScCompiler::CreateStringFromSingleRef( 
OUStringBuffer& rBuffer, const Formu
             OUString aStr = rDoc.GetString(aAbs, mpInterpreterContext);
 
             // If string contains only numeric characters or if it contains 
non-alphanumeric characters
-            // -> quote characters contained within are escaped by '\\'.
+            // -> quote characters contained within are escaped by ''.
             // -> put quotes around string
             sal_Int32 nType = ScGlobal::getCharClass().getStringType( aStr, 0, 
aStr.getLength() );
             if ( CharClass::isNumericType( nType )
                 || !CharClass::isAlphaNumericType( nType ) )
             {
-                aStr = aStr.replaceAll(u"'", u"\\'");
+                aStr = aStr.replaceAll(u"'", u"''");
                 aStr = "'" + aStr + "'";
             }
             rBuffer.append(aStr);

Reply via email to