[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sc/source

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 13 17:59:29 UTC 2020


 sc/source/ui/app/inputhdl.cxx |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

New commits:
commit ff365eb193279bb9866b8fad7378f6068b207051
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Jan 13 16:24:06 2020 +0000
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Jan 13 18:58:59 2020 +0100

    mobile: escape JSON for function wizard, and emit only on mobile.
    
    Otherwise typing "-> wa" into a cell gives JS exceptions.
    
    Change-Id: I5303186fe9f84e055d65cf1929ccf5a7a20cae35
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86705
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 59f6d3c5e809..5c4d4de77f96 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -24,6 +24,7 @@
 #include <editeng/eeitem.hxx>
 
 #include <sfx2/app.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <editeng/acorrcfg.hxx>
 #include <formula/errorcodes.hxx>
 #include <svx/algitem.hxx>
@@ -1289,9 +1290,21 @@ bool ScInputHandler::GetFuncName( OUString& aStart, OUString& aResult )
     return true;
 }
 
+namespace {
+    /// Rid ourselves of unwanted " quoted json characters.
+    OString escapeJSON(const OUString &aStr)
+    {
+        OUString aEscaped = aStr;
+        aEscaped = aEscaped.replaceAll("\n", " ");
+        aEscaped = aEscaped.replaceAll("\"", "'");
+        return OUStringToOString(aEscaped, RTL_TEXTENCODING_UTF8);
+    }
+}
+
 void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec )
 {
-    if (comphelper::LibreOfficeKit::isActive())
+    if (comphelper::LibreOfficeKit::isActive() &&
+        comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()))
     {
         SfxViewShell* pViewShell = SfxViewShell::Current();
         if (pViewShell && rFuncStrVec.size())
@@ -1323,12 +1336,10 @@ void ScInputHandler::ShowFuncList( const ::std::vector< OUString > & rFuncStrVec
                     {
                         aPayload.append("{");
                         aPayload.append("\"signature\": \"");
-                        OUString aSignature = ppFDesc->getSignature();
-                        aPayload.append(OUStringToOString(aSignature, RTL_TEXTENCODING_UTF8));
+                        aPayload.append(escapeJSON(ppFDesc->getSignature()));
                         aPayload.append("\", ");
                         aPayload.append("\"description\": \"");
-                        OUString aFuncDescr = ppFDesc->getDescription();
-                        aPayload.append(OUStringToOString(aFuncDescr, RTL_TEXTENCODING_UTF8));
+                        aPayload.append(escapeJSON(ppFDesc->getDescription()));
                         aPayload.append("\"}, ");
                     }
                 }


More information about the Libreoffice-commits mailing list